@@ -40,16 +40,13 @@ type UpdateStatusJsonBody struct {
40
40
Ref string `json:"ref"`
41
41
}
42
42
43
- /* GetCommit response last_pipeline JSON object */
44
- type GetCommitResponseLastPipeline struct {
45
- ID int `json:"id"`
43
+ type CommitStatus struct {
46
44
Ref string `json:"ref"`
45
+ PipelineID int `json:"pipeline_id"`
47
46
}
48
47
49
- /* GetCommit response JSON object */
50
- type GetCommitResponse struct {
51
- LastPipeline GetCommitResponseLastPipeline `json:"last_pipeline"`
52
- }
48
+ /* GetCommitStatuses response JSON object */
49
+ type GetCommitStatusesResponse []CommitStatus
53
50
54
51
/* Empty struct for JSON marshalling */
55
52
type EmptyStruct struct {}
@@ -348,19 +345,19 @@ func TestGitlabClient_UpdateStatus(t *testing.T) {
348
345
_ , err = w .Write (setStatusJsonResponse )
349
346
Ok (t , err )
350
347
351
- case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha" :
348
+ case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha/statuses?per_page=1&ref=test&sort=desc " :
352
349
w .WriteHeader (http .StatusOK )
353
350
354
- getCommitResponse := GetCommitResponse {
355
- LastPipeline : GetCommitResponseLastPipeline {
356
- ID : gitlabPipelineSuccessMrID ,
351
+ getCommitStatusesResponse := GetCommitStatusesResponse {
352
+ CommitStatus {
357
353
Ref : updateStatusHeadBranch ,
354
+ PipelineID : gitlabPipelineSuccessMrID ,
358
355
},
359
356
}
360
- getCommitJsonResponse , err := json .Marshal (getCommitResponse )
357
+ getCommitStatusesJsonResponse , err := json .Marshal (getCommitStatusesResponse )
361
358
Ok (t , err )
362
359
363
- _ , err = w .Write (getCommitJsonResponse )
360
+ _ , err = w .Write (getCommitStatusesJsonResponse )
364
361
Ok (t , err )
365
362
366
363
case "/api/v4/" :
@@ -471,25 +468,25 @@ func TestGitlabClient_UpdateStatusGetCommitRetryable(t *testing.T) {
471
468
_ , err = w .Write (getCommitJsonResponse )
472
469
Ok (t , err )
473
470
474
- case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha" :
471
+ case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha/statuses?per_page=1&ref=test&sort=desc " :
475
472
handledNumberOfRequests ++
476
473
noCommitLastPipeline := handledNumberOfRequests <= c .commitsWithNoLastPipeline
477
474
478
475
w .WriteHeader (http .StatusOK )
479
476
if noCommitLastPipeline {
480
- getCommitJsonResponse , err := json .Marshal (EmptyStruct {})
477
+ getCommitStatusesJsonResponse , err := json .Marshal ([] EmptyStruct {})
481
478
Ok (t , err )
482
479
483
- _ , err = w .Write (getCommitJsonResponse )
480
+ _ , err = w .Write (getCommitStatusesJsonResponse )
484
481
Ok (t , err )
485
482
} else {
486
- getCommitResponse := GetCommitResponse {
487
- LastPipeline : GetCommitResponseLastPipeline {
488
- ID : gitlabPipelineSuccessMrID ,
483
+ getCommitStatusesResponse := GetCommitStatusesResponse {
484
+ CommitStatus {
489
485
Ref : updateStatusHeadBranch ,
486
+ PipelineID : gitlabPipelineSuccessMrID ,
490
487
},
491
488
}
492
- getCommitJsonResponse , err := json .Marshal (getCommitResponse )
489
+ getCommitJsonResponse , err := json .Marshal (getCommitStatusesResponse )
493
490
Ok (t , err )
494
491
495
492
_ , err = w .Write (getCommitJsonResponse )
@@ -608,19 +605,19 @@ func TestGitlabClient_UpdateStatusSetCommitStatusConflictRetryable(t *testing.T)
608
605
_ , err = w .Write (getCommitJsonResponse )
609
606
Ok (t , err )
610
607
611
- case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha" :
608
+ case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha/statuses?per_page=1&ref=test&sort=desc " :
612
609
w .WriteHeader (http .StatusOK )
613
610
614
- getCommitResponse := GetCommitResponse {
615
- LastPipeline : GetCommitResponseLastPipeline {
616
- ID : gitlabPipelineSuccessMrID ,
611
+ getCommitStatusesResponse := GetCommitStatusesResponse {
612
+ CommitStatus {
617
613
Ref : updateStatusHeadBranch ,
614
+ PipelineID : gitlabPipelineSuccessMrID ,
618
615
},
619
616
}
620
- getCommitJsonResponse , err := json .Marshal (getCommitResponse )
617
+ getCommitStatusesJsonResponse , err := json .Marshal (getCommitStatusesResponse )
621
618
Ok (t , err )
622
619
623
- _ , err = w .Write (getCommitJsonResponse )
620
+ _ , err = w .Write (getCommitStatusesJsonResponse )
624
621
Ok (t , err )
625
622
626
623
case "/api/v4/" :
@@ -721,19 +718,13 @@ func TestGitlabClient_UpdateStatusDifferentRef(t *testing.T) {
721
718
_ , err = w .Write (setStatusJsonResponse )
722
719
Ok (t , err )
723
720
724
- case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha" :
721
+ case "/api/v4/projects/runatlantis%2Fatlantis/repository/commits/sha/statuses?per_page=1&ref=test&sort=desc " :
725
722
w .WriteHeader (http .StatusOK )
726
723
727
- getCommitResponse := GetCommitResponse {
728
- LastPipeline : GetCommitResponseLastPipeline {
729
- ID : gitlabPipelineSuccessMrID ,
730
- Ref : updateStatusHeadBranchDuplicate ,
731
- },
732
- }
733
- getCommitJsonResponse , err := json .Marshal (getCommitResponse )
724
+ getCommitStatusesJsonResponse , err := json .Marshal ([]EmptyStruct {})
734
725
Ok (t , err )
735
726
736
- _ , err = w .Write (getCommitJsonResponse )
727
+ _ , err = w .Write (getCommitStatusesJsonResponse )
737
728
Ok (t , err )
738
729
739
730
case "/api/v4/" :
0 commit comments