Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
feat(eyes-sdk-core): add deleteBatchSessions request to ServerConne…
Browse files Browse the repository at this point in the history
…ctor
  • Loading branch information
astappiev committed Sep 17, 2019
1 parent 40f0bae commit 0728e08
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion packages/eyes-sdk-core/lib/server/ServerConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,30 @@ class ServerConnector {
throw new Error(`ServerConnector.stopSession - unexpected status (${response.statusText})`);
}

/**
* Stops the running session.
*
* @param {string} batchId - The running session to be stopped.
* @return {Promise<TestResults>} - TestResults object for the stopped running session
*/
async deleteBatchSessions(batchId) {
ArgumentGuard.notNull(batchId, 'batchId');
this._logger.verbose(`ServerConnector.deleteBatchSessions called for batchId: ${batchId}`);

const options = this._createHttpOptions({
method: 'DELETE',
url: GeneralUtils.urlConcat(this._configuration.getServerUrl(), EYES_API_PATH, '/batches', batchId, '/close'),
});

const response = await sendRequest(this, 'deleteBatchSessions', options);
const validStatusCodes = [HTTP_STATUS_CODES.OK];
if (validStatusCodes.includes(response.status)) {
this._logger.verbose('ServerConnector.deleteBatchSessions - delete succeeded');
}

throw new Error(`ServerConnector.deleteBatchSessions - unexpected status (${response.statusText})`);
}

/**
* Deletes the given test result
*
Expand All @@ -358,7 +382,7 @@ class ServerConnector {
const response = await sendRequest(this, 'deleteSession', options);
const validStatusCodes = [HTTP_STATUS_CODES.OK];
if (validStatusCodes.includes(response.status)) {
this._logger.verbose('ServerConnector.deleteSession - post succeeded');
this._logger.verbose('ServerConnector.deleteSession - delete succeeded');
return;
}

Expand Down

0 comments on commit 0728e08

Please sign in to comment.