diff --git a/extractor/filesystem/language/dotnet/depsjson/depsjson_test.go b/extractor/filesystem/language/dotnet/depsjson/depsjson_test.go index 4a0dc726..ff6eac62 100644 --- a/extractor/filesystem/language/dotnet/depsjson/depsjson_test.go +++ b/extractor/filesystem/language/dotnet/depsjson/depsjson_test.go @@ -19,7 +19,6 @@ import ( "io/fs" "os" "path/filepath" - "reflect" "testing" "github.com/google/go-cmp/cmp" @@ -63,8 +62,8 @@ func TestNew(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := depsjson.New(tt.cfg) - if !reflect.DeepEqual(got.Config(), tt.wantCfg) { - t.Errorf("New(%+v).Config(): got %+v, want %+v", tt.cfg, got.Config(), tt.wantCfg) + if diff := cmp.Diff(tt.wantCfg, got.Config()); diff != "" { + t.Errorf("New(%+v).Config(): (-want +got):\n%s", tt.cfg, diff) } }) } @@ -280,13 +279,17 @@ func TestExtract(t *testing.T) { got, err := e.Extract(context.Background(), input) - if diff := cmp.Diff(tt.wantInventory, got); diff != "" { + if diff := cmp.Diff(tt.wantInventory, got, cmpopts.SortSlices(invLess)); diff != "" { t.Errorf("Inventory mismatch (-want +got):\n%s", diff) } }) } } +func invLess(i1, i2 *extractor.Inventory) bool { + return i1.Name < i2.Name +} + func TestToPURL(t *testing.T) { e := depsjson.Extractor{} i := &extractor.Inventory{