var assert = require('assert'); var helix_web_services_client = require('../index.js'); var test_methods = require('./util/test_methods'); var string_methods = require('./util/string_methods'); var done = false; test_methods.clientAsJdoe(function (err, c) { if (err) { console.log("ERROR", err); assert(false, "login failed"); return; } var api = c.createDefaultApi(); var rand = string_methods.randomString(); var labelName = "test-label-" + rand; var labelCommand = new helix_web_services_client.models.LabelCommand({ label: labelName, description: labelName, view: [ "//depot/main/" + labelName + "/..." ] }); api.serverLabelsPost("localhost", labelCommand, function(err) { if (err) { console.log("ERROR", err); assert(false); } api.serverLabelsGet("localhost", function(err, labels) { if (err) { console.log("ERROR", err); assert(false); } assert(labels.find(function(b) { return b.label == labelName; }) != null, "did not locate new label"); api.serverLabelsLabelGet("localhost", labelName, function(err, saved) { if (err) { console.log("ERROR", err); assert(false); } assert(saved.view.length == labelCommand.view.length); for (var idx = 0; idx < saved.view.length; ++idx) { assert(saved.view[idx] == labelCommand.view[idx]); } var toUpdate = new helix_web_services_client.models.LabelCommand({ description: "update " + rand }); api.serverLabelsLabelPatch("localhost", labelName, toUpdate, function (err, patchResponse) { if (err) { console.log("ERROR", err); assert(false); } // console.log("patchResponse", patchResponse); api.serverLabelsLabelGet("localhost", labelName, function(err, updated) { if (err) { console.log("ERROR", err); assert(false); } // console.log("toUpdate", toUpdate); // console.log("updated", updated); assert(toUpdate.description.trim() == updated.description.trim()); api.serverLabelsLabelDelete("localhost", labelName, function(err) { if (err) { console.log("ERROR", err); assert(false); } api.serverLabelsGet("localhost", function (err, labels2) { if (err) { console.log("ERROR", err); assert(false); } assert(labels2.find(function(b) { return b.label == labelName; }) == null, "label was not deleted"); done = true; }); }); }); }) }); }); }); }); function checkForDone() { if (!done) { setTimeout(checkForDone, 500); } } setTimeout(checkForDone, 0);
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/test/default_api.server_labels.crud.js | |||||
#1 | 19098 | tjuricek |
JavaScript Client SDK labels spec CRUD tests. Identified another parameter naming conflict, which only pops up in the javaScript client because I didn't choose to automatically rename parameters for people. (I don't think it's a good idea to just say "label0", "label1", etc., especially when they're different types.) |