@@ -201,37 +201,151 @@ describe('PRChecker', () => {
201
201
cli . assertCalledWith ( expectedLogs ) ;
202
202
} ) ;
203
203
204
- it ( 'should skip wait check for Code & Learn PR ' , ( ) => {
204
+ it ( 'should log as expected if PR can be fast-tracked ' , ( ) => {
205
205
const cli = new TestCLI ( ) ;
206
206
207
- const expectedLogs = { } ;
207
+ const expectedLogs = {
208
+ info : [
209
+ [ 'This PR is being fast-tracked' ]
210
+ ]
211
+ } ;
208
212
209
- const now = new Date ( ) ;
210
- const youngPR = Object . assign ( { } , firstTimerPR , {
211
- createdAt : '2017-10-27T14:25 :41.682Z' ,
213
+ const now = new Date ( '2017-11-01T14:25:41.682Z' ) ;
214
+ const PR = Object . assign ( { } , firstTimerPR , {
215
+ createdAt : '2017-10-31T13:00 :41.682Z' ,
212
216
labels : {
213
217
nodes : [
214
- {
215
- name : 'code-and-learn'
216
- }
218
+ { name : 'fast-track' }
217
219
]
218
220
}
219
221
} ) ;
220
222
221
223
const options = {
222
- pr : youngPR ,
224
+ pr : PR ,
223
225
reviewers : allGreenReviewers ,
224
- comments : commentsWithLGTM ,
226
+ comments : commentsWithCI ,
225
227
reviews : approvingReviews ,
226
- commits : simpleCommits ,
228
+ commits : [ ] ,
227
229
collaborators
228
230
} ;
229
231
const checker = new PRChecker ( cli , options , argv ) ;
230
232
233
+ checker . checkCI ( ) ;
234
+ cli . clearCalls ( ) ;
231
235
const status = checker . checkPRWait ( now ) ;
232
236
assert ( status ) ;
233
237
cli . assertCalledWith ( expectedLogs ) ;
234
238
} ) ;
239
+
240
+ it ( 'should warn about approvals and CI for fast-tracked PR' , ( ) => {
241
+ const cli = new TestCLI ( ) ;
242
+
243
+ const expectedLogs = {
244
+ warn : [
245
+ [ 'This PR is being fast-tracked, but awating ' +
246
+ 'approvals of 2 contributors and a CI run' ]
247
+ ]
248
+ } ;
249
+
250
+ const now = new Date ( '2017-11-01T14:25:41.682Z' ) ;
251
+ const PR = Object . assign ( { } , firstTimerPR , {
252
+ createdAt : '2017-10-31T13:00:41.682Z' ,
253
+ labels : {
254
+ nodes : [
255
+ { name : 'fast-track' }
256
+ ]
257
+ }
258
+ } ) ;
259
+
260
+ const options = {
261
+ pr : PR ,
262
+ reviewers : requestedChangesReviewers ,
263
+ comments : [ ] ,
264
+ reviews : requestingChangesReviews ,
265
+ commits : simpleCommits ,
266
+ collaborators
267
+ } ;
268
+ const checker = new PRChecker ( cli , options , argv ) ;
269
+
270
+ checker . checkCI ( ) ;
271
+ cli . clearCalls ( ) ;
272
+ const status = checker . checkPRWait ( now ) ;
273
+ assert ( ! status ) ;
274
+ cli . assertCalledWith ( expectedLogs ) ;
275
+ } ) ;
276
+
277
+ it ( 'should warn cannot be fast-tracked because of approvals' , ( ) => {
278
+ const cli = new TestCLI ( ) ;
279
+
280
+ const expectedLogs = {
281
+ warn : [
282
+ [ 'This PR is being fast-tracked, but awating ' +
283
+ 'approvals of 2 contributors' ]
284
+ ]
285
+ } ;
286
+
287
+ const now = new Date ( '2017-11-01T14:25:41.682Z' ) ;
288
+ const PR = Object . assign ( { } , firstTimerPR , {
289
+ createdAt : '2017-10-31T13:00:41.682Z' ,
290
+ labels : {
291
+ nodes : [
292
+ { name : 'fast-track' }
293
+ ]
294
+ }
295
+ } ) ;
296
+
297
+ const options = {
298
+ pr : PR ,
299
+ reviewers : requestedChangesReviewers ,
300
+ comments : commentsWithCI ,
301
+ reviews : approvingReviews ,
302
+ commits : [ ] ,
303
+ collaborators
304
+ } ;
305
+ const checker = new PRChecker ( cli , options , argv ) ;
306
+
307
+ checker . checkCI ( ) ;
308
+ cli . clearCalls ( ) ;
309
+ const status = checker . checkPRWait ( now ) ;
310
+ assert ( ! status ) ;
311
+ cli . assertCalledWith ( expectedLogs ) ;
312
+ } ) ;
313
+
314
+ it ( 'should warn if the PR has no CI and cannot be fast-tracked' , ( ) => {
315
+ const cli = new TestCLI ( ) ;
316
+
317
+ const expectedLogs = {
318
+ warn : [
319
+ [ 'This PR is being fast-tracked, but awating a CI run' ]
320
+ ]
321
+ } ;
322
+
323
+ const now = new Date ( '2017-11-01T14:25:41.682Z' ) ;
324
+ const PR = Object . assign ( { } , firstTimerPR , {
325
+ createdAt : '2017-10-31T13:00:41.682Z' ,
326
+ labels : {
327
+ nodes : [
328
+ { name : 'fast-track' }
329
+ ]
330
+ }
331
+ } ) ;
332
+
333
+ const options = {
334
+ pr : PR ,
335
+ reviewers : allGreenReviewers ,
336
+ comments : [ ] ,
337
+ reviews : approvingReviews ,
338
+ commits : simpleCommits ,
339
+ collaborators
340
+ } ;
341
+ const checker = new PRChecker ( cli , options , argv ) ;
342
+
343
+ checker . checkCI ( ) ;
344
+ cli . clearCalls ( ) ;
345
+ const status = checker . checkPRWait ( now ) ;
346
+ assert ( ! status ) ;
347
+ cli . assertCalledWith ( expectedLogs ) ;
348
+ } ) ;
235
349
} ) ;
236
350
237
351
describe ( 'checkCI' , ( ) => {
0 commit comments