Created
September 18, 2019 04:25
-
-
Save sauceaaron/e5141ba4b420111405d2059dafc33b11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # usage: node update_sauce_real_device_test_status.js <session_id> <passed|failed> | |
| const request = require('request'); | |
| const SAUCE_USERNAME = process.env.SAUCE_USERNAME; | |
| const SAUCE_RDC_ACCESS_KEY = process.env.SAUCE_RDC_ACCESS_KEY; | |
| const BASIC_AUTH = basic_auth(SAUCE_USERNAME, SAUCE_RDC_ACCESS_KEY); | |
| const SESSION_ID = process.argv[2]; | |
| const TEST_RESULT = process.argv[3]; | |
| function update_sauce_real_device_test_status(session_id, test_result) | |
| { | |
| let UPDATE_SAUCE_RDC_TEST_URL = `https://app.testobject.com/api/rest/v1/appium/session/${session_id}/test`; | |
| console.log(UPDATE_SAUCE_RDC_TEST_URL); | |
| let status = test_result.toLowerCase() == 'passed' ? true : false; | |
| console.log(status); | |
| let options = { | |
| method: 'PUT', | |
| url: UPDATE_SAUCE_RDC_TEST_URL, | |
| headers: { Authorization: BASIC_AUTH }, | |
| body: { passed: status }, | |
| json: true | |
| }; | |
| request(options, function (error, response, body) { | |
| if (error) throw new Error(error); | |
| console.log(response); | |
| }); | |
| } | |
| function basic_auth(username, password) | |
| { | |
| let buffer = Buffer.from(SAUCE_USERNAME + ':' + SAUCE_RDC_ACCESS_KEY); | |
| let encoded = buffer.toString('base64'); | |
| return 'Basic ' + encoded; | |
| } | |
| update_sauce_real_device_test_status(SESSION_ID, TEST_RESULT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment