-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathscenarioColors.js
42 lines (34 loc) · 1.38 KB
/
scenarioColors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const ScenarioSdk = require('@qasymphony/scenario-sdk');
const StepSdk = {
getStepSdk(qtestToken, scenarioProjectId) {
return new ScenarioSdk.Steps({ qtestToken, scenarioProjectId });
}
}
const Steps = {
updateStepResults(stepSdk, name, status) {
return stepSdk.getSteps(`"${name}"`).
then(steps => Promise.all(steps.map(step => stepSdk.updateStep(step.id, Object.assign(step, { status })))))
.catch(function (err) {
console.log('Error updating colors: ' + err);
});
}
};
exports.handler = function ({ event: body, constants, triggers }, context, callback) {
var payload = body;
var testLogs = payload.logs;
stepSdk = StepSdk.getStepSdk(constants.QTEST_TOKEN, constants.SCENARIO_PROJECT_ID);
for (var res of testLogs) {
for (var step of res["test_step_logs"]) {
var stepName = step.description;
var stepStatus = step.status;
// Undefined means no step definition existed and it should fail
if (stepStatus == "undefined") {
stepStatus = "failed";
}
// one of PASSED (green), FAILED (red), or SKIPPED (yellow)
stepStatus = stepStatus.toUpperCase();
// Call the pulse API to update step results
Steps.updateStepResults(stepSdk, stepName, stepStatus);
}
}
}