@@ -112,9 +112,9 @@ var _ = Describe("API", Ordered, func() {
112
112
})
113
113
It ("should return an non-empty list of requests" , func () {
114
114
leaseRequestsPayloadsJSON := buildExpectedRequestsContextPayloads (providerStateOpts .Known , map [string ][]int {
115
- "xxx-1" : rangeInt ( 1 ) ,
116
- "xxx-2" : rangeInt ( 2 ) ,
117
- "xxx-3" : rangeInt ( 3 ) ,
115
+ "xxx-1" : {} ,
116
+ "xxx-2" : {} ,
117
+ "xxx-3" : {} ,
118
118
"xxx-4" : rangeInt (4 ),
119
119
})
120
120
acquiredLeaseRequestPayloadJSON := buildExpectedRequestContextPayload (providerStateOpts .Acquired , rangeInt (4 ))
@@ -181,9 +181,9 @@ var _ = Describe("API", Ordered, func() {
181
181
})
182
182
It ("should return an non-empty list of requests" , func () {
183
183
leaseRequestsPayloadsJSON := buildExpectedRequestsContextPayloads (providerStateOpts .Known , map [string ][]int {
184
- "xxx-1" : rangeInt ( 1 ) ,
185
- "xxx-2" : rangeInt ( 2 ) ,
186
- "xxx-3" : rangeInt ( 3 ) ,
184
+ "xxx-1" : {} ,
185
+ "xxx-2" : {} ,
186
+ "xxx-3" : {} ,
187
187
"xxx-4" : rangeInt (4 ),
188
188
})
189
189
acquiredLeaseRequestPayloadJSON := buildExpectedRequestContextPayload (providerStateOpts .Acquired , rangeInt (4 ))
@@ -309,7 +309,7 @@ var _ = Describe("API", Ordered, func() {
309
309
HeadRef : headRef ,
310
310
Priority : priority ,
311
311
Status : pointer .String (lease .StatusPending ),
312
- }, rangeInt ( configHelper . DefaultConfigRepoExpectedRequestCount - 1 ) )
312
+ }, [] int {} )
313
313
Expect (acquireRespBody ).To (MatchJSON (expectedPayload ))
314
314
})
315
315
})
@@ -428,7 +428,7 @@ var _ = Describe("API", Ordered, func() {
428
428
HeadRef : headRef ,
429
429
Priority : priority ,
430
430
Status : pointer .String (lease .StatusPending ),
431
- }, rangeInt ( 1 ) )
431
+ }, [] int {} )
432
432
Expect (acquireRespBody ).To (MatchJSON (expectedPayload ))
433
433
})
434
434
})
@@ -515,7 +515,7 @@ var _ = Describe("API", Ordered, func() {
515
515
HeadRef : headRef ,
516
516
Priority : priority ,
517
517
Status : pointer .String (lease .StatusCompleted ),
518
- }, rangeInt ( 2 ) )
518
+ }, [] int {} )
519
519
Expect (releaseRespBody ).To (MatchJSON (expectedPayload ))
520
520
})
521
521
})
@@ -531,7 +531,7 @@ var _ = Describe("API", Ordered, func() {
531
531
HeadRef : headRef ,
532
532
Priority : priority ,
533
533
Status : pointer .String (lease .StatusFailure ),
534
- }, rangeInt ( 1 ) )
534
+ }, [] int {} )
535
535
Expect (releaseRespBody ).To (MatchJSON (expectedPayload ))
536
536
})
537
537
})
@@ -555,7 +555,7 @@ var _ = Describe("API", Ordered, func() {
555
555
HeadRef : ref (1 ),
556
556
Priority : 1 ,
557
557
Status : pointer .String (lease .StatusPending ),
558
- }, rangeInt ( 1 ) )))
558
+ }, [] int {} )))
559
559
})
560
560
By ("test acquire, request 2 => should be pending" , func () {
561
561
resp , body := apiCall (srv , acquireReq (owner , repo , baseRef , "xxx-2" , 2 ))
@@ -565,7 +565,7 @@ var _ = Describe("API", Ordered, func() {
565
565
HeadRef : ref (2 ),
566
566
Priority : 2 ,
567
567
Status : pointer .String (lease .StatusPending ),
568
- }, rangeInt ( 2 ) )))
568
+ }, [] int {} )))
569
569
})
570
570
By ("sleeping for stabilize duration" , func () {
571
571
currentTime := now
@@ -580,7 +580,7 @@ var _ = Describe("API", Ordered, func() {
580
580
HeadRef : ref (1 ),
581
581
Priority : 1 ,
582
582
Status : pointer .String (lease .StatusPending ),
583
- }, rangeInt ( 1 ) )))
583
+ }, [] int {} )))
584
584
})
585
585
By ("test acquire, request 2 => should be acquired" , func () {
586
586
resp , body := apiCall (srv , acquireReq (owner , repo , baseRef , "xxx-2" , 2 ))
@@ -600,7 +600,7 @@ var _ = Describe("API", Ordered, func() {
600
600
HeadRef : ref (2 ),
601
601
Priority : 2 ,
602
602
Status : pointer .String (lease .StatusCompleted ),
603
- }, rangeInt ( 2 ) )))
603
+ }, [] int {} )))
604
604
})
605
605
By ("test acquire, request 1 => should be completed" , func () {
606
606
resp , body := apiCall (srv , acquireReq (owner , repo , baseRef , "xxx-1" , 1 ))
@@ -629,7 +629,7 @@ var _ = Describe("API", Ordered, func() {
629
629
HeadRef : ref (1 ),
630
630
Priority : 1 ,
631
631
Status : pointer .String (lease .StatusPending ),
632
- }, rangeInt ( 1 ) )))
632
+ }, [] int {} )))
633
633
})
634
634
By ("test acquire, request 2 => should be pending" , func () {
635
635
resp , body := apiCall (srv , acquireReq (owner , repo , baseRef , "xxx-2" , 2 ))
@@ -639,7 +639,7 @@ var _ = Describe("API", Ordered, func() {
639
639
HeadRef : ref (2 ),
640
640
Priority : 2 ,
641
641
Status : pointer .String (lease .StatusPending ),
642
- }, rangeInt ( 2 ) )))
642
+ }, [] int {} )))
643
643
})
644
644
By ("sleeping for stabilize duration" , func () {
645
645
currentTime := now
@@ -654,7 +654,7 @@ var _ = Describe("API", Ordered, func() {
654
654
HeadRef : ref (1 ),
655
655
Priority : 1 ,
656
656
Status : pointer .String (lease .StatusPending ),
657
- }, rangeInt ( 1 ) )))
657
+ }, [] int {} )))
658
658
})
659
659
By ("test acquire, request 2 => should be acquired" , func () {
660
660
resp , body := apiCall (srv , acquireReq (owner , repo , baseRef , "xxx-2" , 2 ))
@@ -674,7 +674,7 @@ var _ = Describe("API", Ordered, func() {
674
674
HeadRef : ref (2 ),
675
675
Priority : 2 ,
676
676
Status : pointer .String (lease .StatusFailure ),
677
- }, rangeInt ( 1 ) )))
677
+ }, [] int {} )))
678
678
})
679
679
By ("test acquire, request 1 => should be acquired" , func () {
680
680
resp , body := apiCall (srv , acquireReq (owner , repo , baseRef , "xxx-1" , 1 ))
@@ -705,7 +705,7 @@ var _ = Describe("API", Ordered, func() {
705
705
HeadRef : ref (i ),
706
706
Priority : i ,
707
707
Status : pointer .String (lease .StatusPending ),
708
- }, rangeInt ( i ) )))
708
+ }, [] int {} )))
709
709
})
710
710
}
711
711
By (fmt .Sprintf ("test acquire, request %d => should be acquired" , max ), func () {
@@ -726,7 +726,7 @@ var _ = Describe("API", Ordered, func() {
726
726
HeadRef : ref (max ),
727
727
Priority : max ,
728
728
Status : pointer .String (lease .StatusCompleted ),
729
- }, rangeInt ( max ) )))
729
+ }, [] int {} )))
730
730
})
731
731
for i := 1 ; i <= max - 1 ; i ++ {
732
732
By (fmt .Sprintf ("test acquire, request %d => should be completed" , i ), func () {
@@ -759,7 +759,7 @@ var _ = Describe("API", Ordered, func() {
759
759
HeadRef : ref (i ),
760
760
Priority : i ,
761
761
Status : pointer .String (lease .StatusPending ),
762
- }, rangeInt ( i ) )))
762
+ }, [] int {} )))
763
763
})
764
764
}
765
765
By (fmt .Sprintf ("test acquire, request %d => should be acquired" , max ), func () {
@@ -780,7 +780,7 @@ var _ = Describe("API", Ordered, func() {
780
780
HeadRef : ref (max ),
781
781
Priority : max ,
782
782
Status : pointer .String (lease .StatusFailure ),
783
- }, rangeInt ( max - 1 ) )))
783
+ }, [] int {} )))
784
784
})
785
785
for i := 1 ; i <= max - 2 ; i ++ {
786
786
By (fmt .Sprintf ("test acquire, request %d => should be pending" , i ), func () {
@@ -791,7 +791,7 @@ var _ = Describe("API", Ordered, func() {
791
791
HeadRef : ref (i ),
792
792
Priority : i ,
793
793
Status : pointer .String (lease .StatusPending ),
794
- }, rangeInt ( i ) )))
794
+ }, [] int {} )))
795
795
})
796
796
}
797
797
By (fmt .Sprintf ("test acquire, request %d => should be acquired" , max - 1 ), func () {
@@ -937,7 +937,9 @@ func buildExpectedRequestContextPayload(leaseRequest *lease.Request, expectedSta
937
937
"priority" : leaseRequest .Priority ,
938
938
"status" : leaseRequest .Status ,
939
939
},
940
- "stacked_pull_requests" : expectedStackedPulls ,
940
+ }
941
+ if len (expectedStackedPulls ) > 0 {
942
+ raw ["stacked_pull_requests" ] = expectedStackedPulls
941
943
}
942
944
b , _ := json .Marshal (raw )
943
945
0 commit comments