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);
}
var api = c.createDefaultApi();
var rand = string_methods.randomString();
var jobName = "test-job-" + rand;
var jobCommand = new helix_web_services_client.models.JobCommand({
Job: 'new'
});
jobCommand.User = 'jdoe';
jobCommand.Description = jobName + " Description";
jobCommand.Status = "open";
api.serverJobsPost("localhost", jobCommand, function(err, commandResponse) {
if (err) {
console.log("ERROR", err);
assert(false);
}
// console.log("results", commandResponse.results);
var jobId = commandResponse.results[0].job;
// console.log("jobId", jobId);
api.serverJobsGet("localhost", function(err, jobs) {
if (err) {
console.log("ERROR", err);
assert(false);
}
// console.log("jobs", jobs);
assert(jobs.find(function(b) { return b.Job == jobId; }) != null,
"did not locate new job");
api.serverJobsJobGet("localhost", jobId, function(err, saved) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(saved.Description.trim() == (jobName + " Description"));
var toUpdate = new helix_web_services_client.models.JobCommand();
toUpdate.Status = 'closed';
api.serverJobsJobPatch("localhost", jobId, toUpdate, function (err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverJobsJobGet("localhost", jobId, function(err, updated) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(updated.Status == 'closed');
api.serverJobsJobDelete("localhost", jobId, function(err) {
if (err) {
console.log("ERROR", err);
assert(false);
}
api.serverJobsGet("localhost", function (err, jobs2) {
if (err) {
console.log("ERROR", err);
assert(false);
}
assert(jobs2.find(function(b) { return b.job == jobId; }) == null,
"job 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_jobs.crud.js |
#1
|
19169 |
tjuricek |
JavaScript Client SDK jobs CRUD test, with supprt for "additionalProperties" in the swagger definition. |
|
|