@@ -70,6 +70,8 @@ func TestSPRBasicFlowFourCommitsQueue(t *testing.T) {
70
70
githubmock .ExpectGetInfo ()
71
71
s .StatusPullRequests (ctx )
72
72
assert .Equal ("pull request stack is empty\n " , output .String ())
73
+ gitmock .ExpectationsMet ()
74
+ githubmock .ExpectationsMet ()
73
75
output .Reset ()
74
76
75
77
// 'git spr update' :: UpdatePullRequest :: commits=[c1]
@@ -85,6 +87,8 @@ func TestSPRBasicFlowFourCommitsQueue(t *testing.T) {
85
87
s .UpdatePullRequests (ctx , []string {mockclient .NobodyLogin }, nil )
86
88
fmt .Printf ("OUT: %s\n " , output .String ())
87
89
assert .Equal ("[vvvv] 1 : test commit 1\n " , output .String ())
90
+ gitmock .ExpectationsMet ()
91
+ githubmock .ExpectationsMet ()
88
92
output .Reset ()
89
93
90
94
// 'git spr update' :: UpdatePullRequest :: commits=[c1, c2]
@@ -104,6 +108,8 @@ func TestSPRBasicFlowFourCommitsQueue(t *testing.T) {
104
108
assert .Equal ("warning: not updating reviewers for PR #1" , lines [0 ])
105
109
assert .Equal ("[vvvv] 1 : test commit 2" , lines [1 ])
106
110
assert .Equal ("[vvvv] 1 : test commit 1" , lines [2 ])
111
+ gitmock .ExpectationsMet ()
112
+ githubmock .ExpectationsMet ()
107
113
output .Reset ()
108
114
109
115
// 'git spr update' :: UpdatePullRequest :: commits=[c1, c2, c3, c4]
@@ -137,6 +143,8 @@ func TestSPRBasicFlowFourCommitsQueue(t *testing.T) {
137
143
"[vvvv] 1 : test commit 2" ,
138
144
"[vvvv] 1 : test commit 1" ,
139
145
}, lines [:6 ])
146
+ gitmock .ExpectationsMet ()
147
+ githubmock .ExpectationsMet ()
140
148
output .Reset ()
141
149
142
150
// 'git spr merge' :: MergePullRequest :: commits=[a1, a2]
@@ -145,23 +153,28 @@ func TestSPRBasicFlowFourCommitsQueue(t *testing.T) {
145
153
githubmock .ExpectMergePullRequest (c2 , genclient .PullRequestMergeMethod_REBASE )
146
154
githubmock .ExpectCommentPullRequest (c1 )
147
155
githubmock .ExpectClosePullRequest (c1 )
148
- githubmock .ExpectCommentPullRequest (c2 )
149
- githubmock .ExpectClosePullRequest (c2 )
150
156
count := uint (2 )
151
157
s .MergePullRequests (ctx , & count )
152
158
lines = strings .Split (output .String (), "\n " )
153
159
assert .Equal ("MERGED 1 : test commit 1" , lines [0 ])
154
160
assert .Equal ("MERGED 1 : test commit 2" , lines [1 ])
155
161
fmt .Printf ("OUT: %s\n " , output .String ())
162
+ gitmock .ExpectationsMet ()
163
+ githubmock .ExpectationsMet ()
156
164
output .Reset ()
157
165
158
166
githubmock .Info .PullRequests = githubmock .Info .PullRequests [1 :]
159
167
githubmock .Info .PullRequests [0 ].Merged = false
160
168
githubmock .Info .PullRequests [0 ].Commits = append (githubmock .Info .PullRequests [0 ].Commits , c1 , c2 )
169
+ githubmock .ExpectGetInfo ()
170
+ githubmock .ExpectUpdatePullRequest (c2 , nil )
171
+ githubmock .ExpectUpdatePullRequest (c3 , & c2 )
172
+ githubmock .ExpectUpdatePullRequest (c4 , & c3 )
173
+ githubmock .ExpectGetInfo ()
161
174
162
175
gitmock .ExpectFetch ()
163
176
gitmock .ExpectLogAndRespond ([]* git.Commit {& c4 , & c3 , & c2 , & c1 })
164
- gitmock .ExpectPushCommits ([] * git. Commit { & c2 , & c3 , & c4 } )
177
+ gitmock .ExpectStatus ( )
165
178
166
179
s .UpdatePullRequests (ctx , []string {mockclient .NobodyLogin }, nil )
167
180
lines = strings .Split (output .String (), "\n " )
@@ -174,12 +187,12 @@ func TestSPRBasicFlowFourCommitsQueue(t *testing.T) {
174
187
"[vvvv] 1 : test commit 3" ,
175
188
"[vvvv] ! 1 : test commit 2" ,
176
189
}, lines [:6 ])
190
+ gitmock .ExpectationsMet ()
191
+ githubmock .ExpectationsMet ()
177
192
output .Reset ()
178
193
179
194
// 'git spr merge' :: MergePullRequest :: commits=[a2, a3, a4]
180
- gitmock .ExpectLocalBranch ("master" )
181
195
githubmock .ExpectGetInfo ()
182
- gitmock .ExpectLocalBranch ("master" )
183
196
githubmock .ExpectUpdatePullRequest (c4 , nil )
184
197
githubmock .ExpectMergePullRequest (c4 , genclient .PullRequestMergeMethod_REBASE )
185
198
@@ -196,6 +209,8 @@ func TestSPRBasicFlowFourCommitsQueue(t *testing.T) {
196
209
assert .Equal ("MERGED 1 : test commit 3" , lines [1 ])
197
210
assert .Equal ("MERGED 1 : test commit 4" , lines [2 ])
198
211
fmt .Printf ("OUT: %s\n " , output .String ())
212
+ gitmock .ExpectationsMet ()
213
+ githubmock .ExpectationsMet ()
199
214
output .Reset ()
200
215
}
201
216
@@ -229,6 +244,8 @@ func TestSPRBasicFlowFourCommits(t *testing.T) {
229
244
githubmock .ExpectGetInfo ()
230
245
s .StatusPullRequests (ctx )
231
246
assert .Equal ("pull request stack is empty\n " , output .String ())
247
+ gitmock .ExpectationsMet ()
248
+ githubmock .ExpectationsMet ()
232
249
output .Reset ()
233
250
234
251
// 'git spr update' :: UpdatePullRequest :: commits=[c1]
@@ -244,6 +261,8 @@ func TestSPRBasicFlowFourCommits(t *testing.T) {
244
261
s .UpdatePullRequests (ctx , []string {mockclient .NobodyLogin }, nil )
245
262
fmt .Printf ("OUT: %s\n " , output .String ())
246
263
assert .Equal ("[vvvv] 1 : test commit 1\n " , output .String ())
264
+ gitmock .ExpectationsMet ()
265
+ githubmock .ExpectationsMet ()
247
266
output .Reset ()
248
267
249
268
// 'git spr update' :: UpdatePullRequest :: commits=[c1, c2]
@@ -263,6 +282,8 @@ func TestSPRBasicFlowFourCommits(t *testing.T) {
263
282
assert .Equal ("warning: not updating reviewers for PR #1" , lines [0 ])
264
283
assert .Equal ("[vvvv] 1 : test commit 2" , lines [1 ])
265
284
assert .Equal ("[vvvv] 1 : test commit 1" , lines [2 ])
285
+ gitmock .ExpectationsMet ()
286
+ githubmock .ExpectationsMet ()
266
287
output .Reset ()
267
288
268
289
// 'git spr update' :: UpdatePullRequest :: commits=[c1, c2, c3, c4]
@@ -296,12 +317,12 @@ func TestSPRBasicFlowFourCommits(t *testing.T) {
296
317
"[vvvv] 1 : test commit 2" ,
297
318
"[vvvv] 1 : test commit 1" ,
298
319
}, lines [:6 ])
320
+ gitmock .ExpectationsMet ()
321
+ githubmock .ExpectationsMet ()
299
322
output .Reset ()
300
323
301
324
// 'git spr merge' :: MergePullRequest :: commits=[a1, a2, a3, a4]
302
- gitmock .ExpectLocalBranch ("master" )
303
325
githubmock .ExpectGetInfo ()
304
- gitmock .ExpectLocalBranch ("master" )
305
326
githubmock .ExpectUpdatePullRequest (c4 , nil )
306
327
githubmock .ExpectMergePullRequest (c4 , genclient .PullRequestMergeMethod_REBASE )
307
328
githubmock .ExpectCommentPullRequest (c1 )
@@ -317,6 +338,8 @@ func TestSPRBasicFlowFourCommits(t *testing.T) {
317
338
assert .Equal ("MERGED 1 : test commit 3" , lines [2 ])
318
339
assert .Equal ("MERGED 1 : test commit 4" , lines [3 ])
319
340
fmt .Printf ("OUT: %s\n " , output .String ())
341
+ gitmock .ExpectationsMet ()
342
+ githubmock .ExpectationsMet ()
320
343
output .Reset ()
321
344
}
322
345
@@ -375,6 +398,8 @@ func TestSPRMergeCount(t *testing.T) {
375
398
"[vvvv] 1 : test commit 2" ,
376
399
"[vvvv] 1 : test commit 1" ,
377
400
}, lines [:4 ])
401
+ gitmock .ExpectationsMet ()
402
+ githubmock .ExpectationsMet ()
378
403
output .Reset ()
379
404
380
405
// 'git spr merge --count 2' :: MergePullRequest :: commits=[a1, a2, a3, a4]
@@ -388,6 +413,8 @@ func TestSPRMergeCount(t *testing.T) {
388
413
assert .Equal ("MERGED 1 : test commit 1" , lines [0 ])
389
414
assert .Equal ("MERGED 1 : test commit 2" , lines [1 ])
390
415
fmt .Printf ("OUT: %s\n " , output .String ())
416
+ gitmock .ExpectationsMet ()
417
+ githubmock .ExpectationsMet ()
391
418
output .Reset ()
392
419
}
393
420
@@ -411,6 +438,8 @@ func TestSPRAmendCommit(t *testing.T) {
411
438
githubmock .ExpectGetInfo ()
412
439
s .StatusPullRequests (ctx )
413
440
assert .Equal ("pull request stack is empty\n " , output .String ())
441
+ gitmock .ExpectationsMet ()
442
+ githubmock .ExpectationsMet ()
414
443
output .Reset ()
415
444
416
445
// 'git spr update' :: UpdatePullRequest :: commits=[c1, c2]
@@ -428,6 +457,8 @@ func TestSPRAmendCommit(t *testing.T) {
428
457
lines := strings .Split (output .String (), "\n " )
429
458
assert .Equal ("[vvvv] 1 : test commit 2" , lines [0 ])
430
459
assert .Equal ("[vvvv] 1 : test commit 1" , lines [1 ])
460
+ gitmock .ExpectationsMet ()
461
+ githubmock .ExpectationsMet ()
431
462
output .Reset ()
432
463
433
464
// amend commit c2
@@ -445,6 +476,8 @@ func TestSPRAmendCommit(t *testing.T) {
445
476
fmt .Printf ("OUT: %s\n " , output .String ())
446
477
assert .Equal ("[vvvv] 1 : test commit 2" , lines [0 ])
447
478
assert .Equal ("[vvvv] 1 : test commit 1" , lines [1 ])
479
+ gitmock .ExpectationsMet ()
480
+ githubmock .ExpectationsMet ()
448
481
output .Reset ()
449
482
450
483
// amend commit c1
@@ -463,6 +496,8 @@ func TestSPRAmendCommit(t *testing.T) {
463
496
fmt .Printf ("OUT: %s\n " , output .String ())
464
497
assert .Equal ("[vvvv] 1 : test commit 2" , lines [0 ])
465
498
assert .Equal ("[vvvv] 1 : test commit 1" , lines [1 ])
499
+ gitmock .ExpectationsMet ()
500
+ githubmock .ExpectationsMet ()
466
501
output .Reset ()
467
502
468
503
// 'git spr merge' :: MergePullRequest :: commits=[a1, a2]
@@ -471,13 +506,13 @@ func TestSPRAmendCommit(t *testing.T) {
471
506
githubmock .ExpectMergePullRequest (c2 , genclient .PullRequestMergeMethod_REBASE )
472
507
githubmock .ExpectCommentPullRequest (c1 )
473
508
githubmock .ExpectClosePullRequest (c1 )
474
- githubmock .ExpectCommentPullRequest (c2 )
475
- githubmock .ExpectClosePullRequest (c2 )
476
509
s .MergePullRequests (ctx , nil )
477
510
lines = strings .Split (output .String (), "\n " )
478
511
assert .Equal ("MERGED 1 : test commit 1" , lines [0 ])
479
512
assert .Equal ("MERGED 1 : test commit 2" , lines [1 ])
480
513
fmt .Printf ("OUT: %s\n " , output .String ())
514
+ gitmock .ExpectationsMet ()
515
+ githubmock .ExpectationsMet ()
481
516
output .Reset ()
482
517
}
483
518
@@ -516,6 +551,8 @@ func TestSPRReorderCommit(t *testing.T) {
516
551
githubmock .ExpectGetInfo ()
517
552
s .StatusPullRequests (ctx )
518
553
assert .Equal ("pull request stack is empty\n " , output .String ())
554
+ gitmock .ExpectationsMet ()
555
+ githubmock .ExpectationsMet ()
519
556
output .Reset ()
520
557
521
558
// 'git spr update' :: UpdatePullRequest :: commits=[c1, c2, c3, c4]
@@ -539,6 +576,8 @@ func TestSPRReorderCommit(t *testing.T) {
539
576
assert .Equal ("[vvvv] 1 : test commit 3" , lines [1 ])
540
577
assert .Equal ("[vvvv] 1 : test commit 2" , lines [2 ])
541
578
assert .Equal ("[vvvv] 1 : test commit 1" , lines [3 ])
579
+ gitmock .ExpectationsMet ()
580
+ githubmock .ExpectationsMet ()
542
581
output .Reset ()
543
582
544
583
// 'git spr update' :: UpdatePullRequest :: commits=[c2, c4, c1, c3]
@@ -568,6 +607,8 @@ func TestSPRReorderCommit(t *testing.T) {
568
607
//assert.Equal("[vvvv] 1 : test commit 1", lines[1])
569
608
//assert.Equal("[vvvv] 1 : test commit 4", lines[2])
570
609
//assert.Equal("[vvvv] 1 : test commit 2", lines[3])
610
+ gitmock .ExpectationsMet ()
611
+ githubmock .ExpectationsMet ()
571
612
output .Reset ()
572
613
573
614
// 'git spr update' :: UpdatePullRequest :: commits=[c5, c1, c2, c3, c4]
@@ -600,6 +641,8 @@ func TestSPRReorderCommit(t *testing.T) {
600
641
//assert.Equal("[vvvv] 1 : test commit 3", lines[2])
601
642
//assert.Equal("[vvvv] 1 : test commit 2", lines[3])
602
643
//assert.Equal("[vvvv] 1 : test commit 1", lines[4])
644
+ gitmock .ExpectationsMet ()
645
+ githubmock .ExpectationsMet ()
603
646
output .Reset ()
604
647
605
648
// TODO : add a call to merge and check merge order
@@ -635,6 +678,8 @@ func TestSPRDeleteCommit(t *testing.T) {
635
678
githubmock .ExpectGetInfo ()
636
679
s .StatusPullRequests (ctx )
637
680
assert .Equal ("pull request stack is empty\n " , output .String ())
681
+ gitmock .ExpectationsMet ()
682
+ githubmock .ExpectationsMet ()
638
683
output .Reset ()
639
684
640
685
// 'git spr update' :: UpdatePullRequest :: commits=[c1, c2, c3, c4]
@@ -659,6 +704,8 @@ func TestSPRDeleteCommit(t *testing.T) {
659
704
assert .Equal ("[vvvv] 1 : test commit 3" , lines [1 ])
660
705
assert .Equal ("[vvvv] 1 : test commit 2" , lines [2 ])
661
706
assert .Equal ("[vvvv] 1 : test commit 1" , lines [3 ])
707
+ gitmock .ExpectationsMet ()
708
+ githubmock .ExpectationsMet ()
662
709
output .Reset ()
663
710
664
711
// 'git spr update' :: UpdatePullRequest :: commits=[c2, c4, c1, c3]
@@ -684,6 +731,8 @@ func TestSPRDeleteCommit(t *testing.T) {
684
731
//assert.Equal("[vvvv] 1 : test commit 1", lines[1])
685
732
//assert.Equal("[vvvv] 1 : test commit 4", lines[2])
686
733
//assert.Equal("[vvvv] 1 : test commit 2", lines[3])
734
+ gitmock .ExpectationsMet ()
735
+ githubmock .ExpectationsMet ()
687
736
output .Reset ()
688
737
689
738
// TODO : add a call to merge and check merge order
@@ -753,18 +802,21 @@ func TestAmendInvalidInput(t *testing.T) {
753
802
input .WriteString ("a" )
754
803
s .AmendCommit (ctx )
755
804
assert .Equal (" 1 : 00000001 : test commit 1\n Commit to amend (1): Invalid input\n " , output .String ())
805
+ gitmock .ExpectationsMet ()
756
806
output .Reset ()
757
807
758
808
gitmock .ExpectLogAndRespond ([]* git.Commit {& c1 })
759
809
input .WriteString ("0" )
760
810
s .AmendCommit (ctx )
761
811
assert .Equal (" 1 : 00000001 : test commit 1\n Commit to amend (1): Invalid input\n " , output .String ())
812
+ gitmock .ExpectationsMet ()
762
813
output .Reset ()
763
814
764
815
gitmock .ExpectLogAndRespond ([]* git.Commit {& c1 })
765
816
input .WriteString ("2" )
766
817
s .AmendCommit (ctx )
767
818
assert .Equal (" 1 : 00000001 : test commit 1\n Commit to amend (1): Invalid input\n " , output .String ())
819
+ gitmock .ExpectationsMet ()
768
820
output .Reset ()
769
821
}
770
822
0 commit comments