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 userName = "test-user-" + rand;
var userCommand = new helix_web_services_client.models.UserCommand({
user: userName,
fullName: "Test User",
email: userName + "@example.com",
jobView: "Owned-By=" + userName + "&status=open",
reviews: [ "//depot/dev/...", "//depot/main/..." ]
});
api.serverUsersPost("localhost", userCommand, function(err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverUsersGet("localhost", null, null, function(err, users) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(users.find(function(b) { return b.user == userName; }) != null,
"did not locate new user");
api.serverUsersUserGet("localhost", userName, function(err, saved) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(saved.fullName == userCommand.fullName);
assert(saved.jobView == userCommand.jobView);
assert(saved.reviews.length == userCommand.reviews.length);
for (var idx = 0; idx < saved.reviews.length; ++idx) {
assert(saved.reviews[idx] == userCommand.reviews[idx]);
}
var toUpdate = new helix_web_services_client.models.UserCommand({
fullName: "updated " + rand
});
api.serverUsersUserPatch("localhost", userName, toUpdate, function (err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverUsersUserGet("localhost", userName, function(err, updated) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(toUpdate.fullName.trim() == updated.fullName.trim());
api.serverUsersUserDelete("localhost", userName, function(err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverUsersGet("localhost", null, null, function (err, users2) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(users2.find(function(b) { return b.user == userName; }) == null,
"user 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_users.crud.js |
#1
|
19184 |
tjuricek |
JavaScript Client SDK tests for paths, protections, servers, triggers, users |
|
|