$:.push File.expand_path("../../lib", __FILE__) require 'helix_web_services_client' require_relative './util/test_config' require_relative './util/string_utils' require 'pp' api = api_as_jdoe rand = random_string label_id = "test-label-#{random_string}" label_command = HelixWebServices::LabelCommand.new( label: label_id, description: "test #{label_id}", view: [ "//depot/main/#{label_id}/..." ] ) api.server_labels_post('localhost', label_command) all_labels = api.server_labels_get('localhost') unless all_labels.any? { |b| b.label == label_id } raise "Did not locate label #{label_id}" end saved_label = api.server_labels_label_get('localhost', label_id) raise 'view was not saved' if saved_label.view != label_command.view to_update = HelixWebServices::LabelCommand.new( description: "Update #{rand}" ) api.server_labels_label_patch('localhost', label_id, to_update) updated = api.server_labels_label_get('localhost', label_id) raise 'label not updated' if updated.description.strip != to_update.description.strip api.server_labels_label_delete('localhost', label_id) all_labels2 = api.server_labels_get('localhost') if all_labels2.any? { |b| b.label == label_id } raise "Did not delete label #{label_id}" end