-
Notifications
You must be signed in to change notification settings - Fork 3
TSERV-907: Delete a test job #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. formatting, add space around operators |
||
| request.delete(url) | ||
| .auth(config.username, config.password) | ||
| .accept('application/junit+xml') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This accept looks weird to me, I think it could be application/json, since json is what we return when there is an error. On success we don't return any data. Same goes for cancel(which I know you havent changed but I think it can be fixed too). |
||
| .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']); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is does the same as the default-case. So it can be removed. Maybe we dont need the switch at all? |
||
| 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'; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The slash can be part of the first string and doesnt need to be concateneted seperately.
'/api/v1/testjobs'+ '/' + testjobId + '/delete';
->
'/api/v1/testjobs/' + testjobId + '/delete'