зеркало из https://github.com/golang/pkgsite.git
internal/fetch: fix license sorting in TestFetchAndInsertVersion
Licenses were being sorted by Type, which need not be unique. Instead, they should be sorted by FilePath. Change-Id: I28205a6a0b075d8dd298b31846007009a24d3d18 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/456233 Reviewed-by: Julie Qiu <julieqiu@google.com>
This commit is contained in:
Родитель
d88ea7bb53
Коммит
d5be5cee64
|
@ -85,11 +85,11 @@ func TestFetchAndInsertVersion(t *testing.T) {
|
|||
Synopsis: "package baz",
|
||||
Suffix: "bar/baz",
|
||||
Licenses: []*internal.LicenseInfo{
|
||||
{Type: "BSD-0-Clause", FilePath: "bar/baz/LICENSE"},
|
||||
{Type: "BSD-0-Clause", FilePath: "LICENSE.txt"},
|
||||
{Type: "BSD-3-Clause", FilePath: "LICENSE"},
|
||||
{Type: "MIT", FilePath: "bar/baz/COPYING"},
|
||||
{Type: "BSD-0-Clause", FilePath: "LICENSE.txt"},
|
||||
{Type: "MIT", FilePath: "bar/LICENSE"},
|
||||
{Type: "MIT", FilePath: "bar/baz/COPYING"},
|
||||
{Type: "BSD-0-Clause", FilePath: "bar/baz/LICENSE"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -113,9 +113,9 @@ func TestFetchAndInsertVersion(t *testing.T) {
|
|||
Synopsis: "",
|
||||
Suffix: "foo",
|
||||
Licenses: []*internal.LicenseInfo{
|
||||
{Type: "BSD-0-Clause", FilePath: "foo/LICENSE.md"},
|
||||
{Type: "BSD-0-Clause", FilePath: "LICENSE.txt"},
|
||||
{Type: "BSD-3-Clause", FilePath: "LICENSE"},
|
||||
{Type: "BSD-0-Clause", FilePath: "LICENSE.txt"},
|
||||
{Type: "BSD-0-Clause", FilePath: "foo/LICENSE.md"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -148,7 +148,7 @@ func TestFetchAndInsertVersion(t *testing.T) {
|
|||
}
|
||||
|
||||
sort.Slice(gotPkg.Licenses, func(i, j int) bool {
|
||||
return gotPkg.Licenses[i].Type < gotPkg.Licenses[j].Type
|
||||
return gotPkg.Licenses[i].FilePath < gotPkg.Licenses[j].FilePath
|
||||
})
|
||||
if diff := cmp.Diff(test.want, gotPkg); diff != "" {
|
||||
t.Errorf("testDB.GetPackage(ctx, %q, %q) mismatch (-want +got):\n%s", test.pkg, test.version, diff)
|
||||
|
|
Загрузка…
Ссылка в новой задаче