Repository navigation
Expand file tree
/
Copy pathrelease.test.js
More file actions
275 lines (259 loc) · 10.4 KB
/
Copy pathrelease.test.js
File metadata and controls
275 lines (259 loc) · 10.4 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
const { app } = require('../../../bin/app');
const request = require('supertest')(app);
const should = require('should');
const path = require('path');
const _ = require('lodash');
const SLEEP_TIME = 5000;
describe('api/apps/release.test.js', function () {
var account = '522539441@qq.com';
var password = '123456';
var authToken;
var machineName = `Login-${Math.random()}`;
var friendlyName = `Login-${Math.random()}`;
var appName = 'Demo-ios';
var bearerToken;
before(function (done) {
request
.post('/auth/login')
.send({
account: account,
password: password,
})
.end(function (err, res) {
should.not.exist(err);
var rs = JSON.parse(res.text);
rs.should.containEql({ status: 'OK' });
authToken = Buffer.from(`auth:${_.get(rs, 'results.tokens')}`).toString('base64');
done();
});
});
describe('create accessKeys', function (done) {
it('should create accessKeys successful', function (done) {
request
.post(`/accessKeys`)
.set('Authorization', `Basic ${authToken}`)
.send({
createdBy: machineName,
friendlyName: friendlyName,
ttl: 30 * 24 * 60 * 60,
})
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
var rs = JSON.parse(res.text);
rs.should.have.properties('accessKey');
rs.accessKey.should.have.properties([
'name',
'createdTime',
'createdBy',
'expires',
'description',
'friendlyName',
]);
bearerToken = _.get(rs, 'accessKey.name');
done();
});
});
});
describe('add apps', function (done) {
it('should add apps successful', function (done) {
request
.post(`/apps`)
.set('Authorization', `Bearer ${bearerToken}`)
.send({ name: appName, os: 'iOS', platform: 'React-Native' })
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
var rs = JSON.parse(res.text);
rs.should.have.properties('app');
rs.app.should.have.properties(['name', 'collaborators']);
done();
});
});
});
describe('release apps', function (done) {
it('should release apps successful', function (done) {
request
.post(`/apps/${appName}/deployments/Staging/release`)
.set('Authorization', `Bearer ${bearerToken}`)
.attach('package', path.resolve(__dirname, './bundle.zip'))
.field(
'packageInfo',
`{"appVersion": "1.0.0", "description": "test", "isMandatory": false}`,
)
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
done();
});
});
it('should release apps v2 successful', function (done) {
request
.post(`/apps/${appName}/deployments/Staging/release`)
.set('Authorization', `Bearer ${bearerToken}`)
.attach('package', path.resolve(__dirname, './bundle_v2.zip'))
.field(
'packageInfo',
`{"appVersion": "1.0.0", "description": "test", "isMandatory": false}`,
)
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
setTimeout(function () {
done();
}, SLEEP_TIME);
});
});
});
describe('promote apps', function (done) {
it('should promote apps successful', function (done) {
request
.post(`/apps/${appName}/deployments/Staging/promote/Production`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
res.status.should.equal(200);
done();
});
});
});
describe('rollback deployments', function (done) {
it('should rollback deployments successful when point labels', function (done) {
request
.post(`/apps/${appName}/deployments/Staging/rollback/v1`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
res.text.should.equal(`ok`);
setTimeout(function () {
done();
}, SLEEP_TIME);
});
});
it('should rollback deployments successful', function (done) {
request
.post(`/apps/${appName}/deployments/Staging/rollback`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
res.text.should.equal(`ok`);
setTimeout(function () {
done();
}, SLEEP_TIME);
});
});
});
describe('show deployments history', function (done) {
it('should not show deployments history successful where deployments does not exist', function (done) {
request
.get(`/apps/${appName}/deployments/Test/history`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(406);
res.text.should.equal(`does not find the deployment`);
done();
});
});
it('should show deployments history successful', function (done) {
request
.get(`/apps/${appName}/deployments/Staging/history`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
var rs = JSON.parse(res.text);
rs.should.have.properties('history');
rs.history.should.be.an.instanceOf(Array);
rs.history.should.matchEach(function (it) {
return it.should.have.properties([
'description',
'isDisabled',
'isMandatory',
'rollout',
'appVersion',
'packageHash',
'blobUrl',
'size',
'manifestBlobUrl',
'diffPackageMap',
'releaseMethod',
'uploadTime',
'originalLabel',
'originalDeployment',
'label',
'releasedBy',
]);
});
done();
});
});
});
describe('delete deployments history', function (done) {
it('should not delete deployments history successful where deployments does not exist', function (done) {
request
.delete(`/apps/${appName}/deployments/Test/history`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(406);
res.text.should.equal(`does not find the deployment`);
done();
});
});
it('should delete deployments history successful', function (done) {
request
.delete(`/apps/${appName}/deployments/Staging/history`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
res.text.should.equal(`ok`);
done();
});
});
});
describe('show deployments metrics', function (done) {
it('should not show deployments metrics successful where deployments does not exist', function (done) {
request
.get(`/apps/${appName}/deployments/Test/metrics`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
done();
});
});
it('should show deployments metrics successful', function (done) {
request
.get(`/apps/${appName}/deployments/Staging/metrics`)
.set('Authorization', `Bearer ${bearerToken}`)
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(200);
var rs = JSON.parse(res.text);
rs.should.have.properties('metrics');
rs.metrics.should.be.an.instanceOf(Object);
rs.metrics.should.matchEach(function (it) {
return it.should.have.properties([
'active',
'downloaded',
'failed',
'installed',
]);
});
done();
});
});
});
});