@@ -186,10 +186,9 @@ func TestClientSearchSuccessFromFakeUpstream(t *testing.T) {
186186 "total" : 1 ,
187187 "items" : []map [string ]any {
188188 {
189- "name" : "uuid" ,
190- "path" : "github.com/google/uuid" ,
191- "modulePath" : "github.com/google/uuid" ,
192- "version" : "v1.6.0" ,
189+ "packagePath" : "github.com/google/uuid" ,
190+ "modulePath" : "github.com/google/uuid" ,
191+ "version" : "v1.6.0" ,
193192 },
194193 },
195194 })
@@ -211,7 +210,7 @@ func TestClientSearchSuccessFromFakeUpstream(t *testing.T) {
211210 "symbol" : "" ,
212211 "count" : 1 ,
213212 })
214- assertItemNames (t , got .Items , []string {"uuid" })
213+ assertItemPackagePaths (t , got .Items , []string {"github.com/google/ uuid" })
215214 assertPagination (t , got , 1 , 1 , "" )
216215}
217216
@@ -225,9 +224,9 @@ func TestClientSearchSingleResultSchedulesPackageWarm(t *testing.T) {
225224 writeJSON (t , w , http .StatusOK , map [string ]any {
226225 "total" : 1 ,
227226 "items" : []map [string ]any {{
228- "path" : "github.com/google/uuid" ,
229- "modulePath" : "github.com/google/uuid" ,
230- "version" : "v1.6.0" ,
227+ "packagePath" : "github.com/google/uuid" ,
228+ "modulePath" : "github.com/google/uuid" ,
229+ "version" : "v1.6.0" ,
231230 }},
232231 })
233232 }, WithWarmer (warmer ))
@@ -251,8 +250,8 @@ func TestClientSearchMultipleResultsDoesNotWarm(t *testing.T) {
251250 writeJSON (t , w , http .StatusOK , map [string ]any {
252251 "total" : 2 ,
253252 "items" : []map [string ]any {
254- {"path " : "example.com/one" },
255- {"path " : "example.com/two" },
253+ {"packagePath " : "example.com/one" },
254+ {"packagePath " : "example.com/two" },
256255 },
257256 })
258257 }, WithWarmer (warmer ))
@@ -319,7 +318,7 @@ func TestClientUpstream4xxReturnsStructuredResultError(t *testing.T) {
319318 name : "module not found" ,
320319 status : http .StatusNotFound ,
321320 body : map [string ]any {
322- "code" : "not_found" ,
321+ "code" : http . StatusNotFound ,
323322 "message" : "module not found" ,
324323 },
325324 callFunc : func (t * testing.T , client * Client ) (Result , error ) {
@@ -331,7 +330,7 @@ func TestClientUpstream4xxReturnsStructuredResultError(t *testing.T) {
331330 name : "search bad request" ,
332331 status : http .StatusBadRequest ,
333332 body : map [string ]any {
334- "code" : "bad_request" ,
333+ "code" : http . StatusBadRequest ,
335334 "message" : "missing query" ,
336335 },
337336 callFunc : func (t * testing.T , client * Client ) (Result , error ) {
@@ -367,7 +366,7 @@ func TestClientUpstream4xxReturnsStructuredResultError(t *testing.T) {
367366 if ! json .Valid (got .Error .Body ) {
368367 t .Fatalf ("Result.Error.Body is not valid JSON: %q" , string (got .Error .Body ))
369368 }
370- for _ , want := range []string {tt .body ["code" ].( string ), tt .body ["message" ].(string )} {
369+ for _ , want := range []string {fmt . Sprint ( tt .body ["code" ]), tt .body ["message" ].(string )} {
371370 if ! strings .Contains (got .Error .Message , want ) {
372371 t .Fatalf ("message %q does not contain %q" , got .Error .Message , want )
373372 }
@@ -623,6 +622,22 @@ func assertItemNames(t testing.TB, items []map[string]any, want []string) {
623622 }
624623}
625624
625+ func assertItemPackagePaths (t testing.TB , items []map [string ]any , want []string ) {
626+ t .Helper ()
627+
628+ got := make ([]string , 0 , len (items ))
629+ for _ , item := range items {
630+ path , ok := item ["packagePath" ].(string )
631+ if ! ok {
632+ t .Fatalf ("item package path = %#v, want string" , item ["packagePath" ])
633+ }
634+ got = append (got , path )
635+ }
636+ if ! slices .Equal (got , want ) {
637+ t .Fatalf ("item package paths = %#v, want %#v" , got , want )
638+ }
639+ }
640+
626641func assertItemPaths (t testing.TB , items []map [string ]any , want []string ) {
627642 t .Helper ()
628643
0 commit comments