File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,11 @@ func unexpectedBody(kind string) error {
315315}
316316
317317func compareDependencySubmissionRequest (expect , actual model.DependencySubmissionRequest ) error {
318+ // since the detector version will change all the time, ignore that in the comparison
319+ tmp := expect .Detector ["version" ]
320+ defer func () { expect .Detector ["version" ] = tmp }()
321+ expect .Detector ["version" ] = actual .Detector ["version" ]
322+
318323 if reflect .DeepEqual (expect , actual ) {
319324 return nil
320325 }
Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import (
77 "encoding/hex"
88 "encoding/json"
99 "fmt"
10- "github.com/dependabot/cli/internal/model"
1110 "net/http"
1211 "net/http/httptest"
1312 "testing"
13+
14+ "github.com/dependabot/cli/internal/model"
1415)
1516
1617func Test_decodeWrapper (t * testing.T ) {
@@ -103,3 +104,28 @@ func TestAPI_CreatePullRequest_ReplacesBinaryWithHash(t *testing.T) {
103104 t .Errorf ("expected stdout to contain the original content, got '%s'" , stdout .String ())
104105 }
105106}
107+
108+ func TestAPI_compareDependencySubmissionRequest (t * testing.T ) {
109+ t .Run ("ignores detector version" , func (t * testing.T ) {
110+ expect := model.DependencySubmissionRequest {
111+ Detector : map [string ]any {
112+ "version" : "1.2.3" ,
113+ },
114+ }
115+ actual := model.DependencySubmissionRequest {
116+ Detector : map [string ]any {
117+ "version" : "4.5.6" ,
118+ },
119+ }
120+
121+ if compareDependencySubmissionRequest (expect , actual ) != nil {
122+ t .Error ("expected detector version to be ignored" )
123+ }
124+ if expect .Detector ["version" ] != "1.2.3" {
125+ t .Error ("expected expect detector version to be unchanged" )
126+ }
127+ if actual .Detector ["version" ] != "4.5.6" {
128+ t .Error ("expected actual detector version to be unchanged" )
129+ }
130+ })
131+ }
You can’t perform that action at this time.
0 commit comments