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.clientAsSuper(function (err, c) {
if (err) {
console.log("ERROR", err);
assert(false);
}
var api = c.createDefaultApi();
var rand = string_methods.randomString();
var groupName = "test-group-" + rand;
var groupCommand = new helix_web_services_client.models.GroupCommand({
group: groupName,
users: ["jdoe"],
owners: ["jdoe"]
});
api.serverGroupsPost("localhost", groupCommand, function(err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverGroupsGet("localhost", function(err, allGroups) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(allGroups.find(function(b) { return b.group == groupName; }) != null,
"did not locate new group");
api.serverGroupsGroupGet("localhost", groupName, function(err, saved) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(saved.users.length == groupCommand.users.length);
for (var idx = 0; idx < saved.users.length; ++idx) {
assert(saved.users[idx] == groupCommand.users[idx]);
}
assert(saved.owners.length == groupCommand.owners.length);
for (var idx = 0; idx < saved.owners.length; ++idx) {
assert(saved.owners[idx] == groupCommand.owners[idx]);
}
var toUpdate = new helix_web_services_client.models.GroupCommand({
users: ['mmustermann']
});
api.serverGroupsGroupPatch("localhost", groupName, toUpdate, function (err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverGroupsGroupGet("localhost", groupName, function(err, updated) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(updated.users.find(function (x) { return x == "mmustermann"; }) != null);
api.serverGroupsGroupDelete("localhost", groupName, function(err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverGroupsGet("localhost", function (err, groups2) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(groups2.find(function(b) { return b.group == groupName; }) == null,
"group 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_groups.crud.js |
#1
|
19128 |
tjuricek |
Javascript client SDK group CRUD tests, and a wee bit of refinement on the branches spec |
|
|