-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
106 lines (88 loc) · 2.66 KB
/
test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'use strict';
var Service = require("./lib/client.js");
var fs = require('fs');
// var q = require('q');
function now() {
return new Date().getTime();
}
var status = {
PASSED: 'passed',
FAILED: 'failed',
SKIPPED: 'skipped'
};
var rpConfig = {
endpoint: "https://rp_url",
project: "project_name",
token: "user_token"
};
var rp = new Service(rpConfig);
var startLaunchRQ = {
name: "JSLaunchName",
description: "Some LaunchDescription",
tags: ["tag1", "tag2"],
start_time: now(),
mode: null
};
var startLaunchResponse = rp.startLaunch(startLaunchRQ);
var launchId;
startLaunchResponse.then(function (response) {
var startTestItemRQ = {
name: "Test1",
description: "TestDescription",
tags: ["tag1", "tag2"],
start_time: now(),
launch_id: response.id,
type: "TEST"
};
var startTestResponse = rp.startTestItem(null, startTestItemRQ);
startTestResponse.then(function (data) {
var testItemId = data.id;
var saveLogRQ = {
item_id: testItemId,
time: now(),
message: "logmessage"
// level: "TRACE"
};
var contents = fs.readFileSync("image.jpg", 'base64');
var postLogResponse = rp.sendFile(saveLogRQ, "image.jpg", contents, "image/jpg");
postLogResponse.then(function (data) {
// console.log(data);
var finishTestItemRQ = {
end_time: now(),
status: status.PASSED
};
rp.finishTestItem(testItemId, finishTestItemRQ).then(function (data) {
var finishExecutionRQ = {
end_time: now(),
status: status.PASSED
};
startLaunchResponse.then(function (response) {
console.log(response.id);
rp.finishLaunch(response.id, finishExecutionRQ)
.then(function (data) {
console.log(data);
})
}, function (err) {
console.log(err);
});
});
});
})
});
// console.log(launchId);
// var startTestItemRQ = {
// name: "Suite1",
// description: "SuiteDescription",
// tags: ["suite_tag1", "suite_tag2"],
// start_time: now(),
// launch_id: launchId,
// type: "SUITE"
// };
// var startSuiteResponse = rp.startTestItem(null, startTestItemRQ);
// startSuiteResponse.then(function(data){
// var finishTestItemRQ = {
// end_time : now(),
// status : status.PASSED
// }
// rp.finishTestItem(data.id, finishTestItemRQ);
// })