diff --git a/README.md b/README.md index 789f2e6..8715266 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ is to run ReadyAPI projects (functional API tests for primarily REST and SOAP se The TestEngine-CLI is a command line interface for the API of the product. The tool can handle most administration of the server as well as submitting test jobs and requesting reports. +## Install +Install testengine cli globally: + +`npm install -g testengine-cli` ## Usage All communication with the ReadyAPI TestEngine requires three settings. * URL to TestEngine @@ -112,6 +116,11 @@ Each job has a job ID, with the command "jobs cancel" a running (or queued) job `testengine jobs cancel ` +### Delete a job +Each job has a job ID, with the command "jobs delete" a job can be deleted. A running/queued job must be canceled first to delete. + +`testengine jobs delete ` + ### Get the status of a job, using job ID without generating a report Each job has a job ID, with the command "jobs cancel" a running (or queued) job can be canceled. diff --git a/bin/jobs_functions.js b/bin/jobs_functions.js index a20a3f0..1220d4e 100644 --- a/bin/jobs_functions.js +++ b/bin/jobs_functions.js @@ -26,6 +26,14 @@ module.exports = { } break; } + case 'delete': { + if (args.length < 2) { + printModuleHelp(); + } else { + deleteTestJob(args[1]); + } + break; + } case 'status': { if (args.length < 2) { printModuleHelp(); @@ -114,6 +122,36 @@ function terminateTestJob(testjobId) { }) } +function deleteTestJob(testjobId) { + let url = config.server + '/api/v1/testjobs'+ '/' + testjobId + '/delete'; + util.output('Deleting job: '+testjobId); + request.delete(url) + .auth(config.username, config.password) + .accept('application/junit+xml') + .send() + .end((err, result) => { + if (err !== null) { + if (('status' in err) && ('message' in result.body)) { + switch (err['status']) { + case 403: + util.error(err['status'] + ': ' + result.body['message']); + break; + case 404: + util.output(`${err['status']}: Testjob not found`); + break; + default: + util.error(err['status'] + ': ' + result.body['message']); + return; + } + } else { + util.error(err); + } + } else { + util.output('Successfully deleted job'); + } + }) +} + function printReport (testjobId) { const endPoint = config.server + '/api/v1/testjobs'; const url = endPoint + '/' + testjobId + '/report';