internal/proxydatasource: replace LegacyPackage with Unit
For golang/go#39629
Change-Id: I3549e4ef1c0328bf266451db80ce1c92e5aee4eb
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/262763
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/proxydatasource/datasource.go b/internal/proxydatasource/datasource.go
index f105038..767820a 100644
--- a/internal/proxydatasource/datasource.go
+++ b/internal/proxydatasource/datasource.go
@@ -92,7 +92,7 @@
if m != nil {
if ds.bypassLicenseCheck {
m.IsRedistributable = true
- for _, pkg := range m.LegacyPackages {
+ for _, pkg := range m.Packages() {
pkg.IsRedistributable = true
}
} else {
@@ -118,7 +118,7 @@
// be a bit more careful and check that it is new. To do this, we can
// leverage the invariant that module paths in packagePathToModules are kept
// sorted in descending order of length.
- for _, pkg := range m.LegacyPackages {
+ for _, pkg := range m.Packages() {
var (
i int
mp string
diff --git a/internal/proxydatasource/datasource_test.go b/internal/proxydatasource/datasource_test.go
index 5fd740b..6c1ced5 100644
--- a/internal/proxydatasource/datasource_test.go
+++ b/internal/proxydatasource/datasource_test.go
@@ -63,16 +63,22 @@
var (
wantLicenseMD = sample.LicenseMetadata[0]
- wantPackage = internal.LegacyPackage{
- Path: "foo.com/bar/baz",
- Name: "baz",
- Imports: []string{"net/http"},
- Synopsis: "Package baz provides a helpful constant.",
- V1Path: "foo.com/bar/baz",
- Licenses: []*licenses.Metadata{wantLicenseMD},
- IsRedistributable: true,
- GOOS: "linux",
- GOARCH: "amd64",
+ wantPackage = internal.Unit{
+ UnitMeta: internal.UnitMeta{
+ Path: "foo.com/bar/baz",
+ Name: "baz",
+ ModulePath: "foo.com/bar",
+ Version: "v1.2.0",
+ CommitTime: time.Date(2019, 1, 30, 0, 0, 0, 0, time.UTC),
+ Licenses: []*licenses.Metadata{wantLicenseMD},
+ IsRedistributable: true,
+ },
+ Imports: []string{"net/http"},
+ Documentation: &internal.Documentation{
+ Synopsis: "Package baz provides a helpful constant.",
+ GOOS: "linux",
+ GOARCH: "amd64",
+ },
}
wantModuleInfo = internal.ModuleInfo{
ModulePath: "foo.com/bar",
@@ -82,7 +88,7 @@
HasGoMod: true,
}
cmpOpts = append([]cmp.Option{
- cmpopts.IgnoreFields(internal.LegacyPackage{}, "DocumentationHTML"),
+ cmpopts.IgnoreFields(internal.Documentation{}, "HTML"),
cmpopts.IgnoreFields(licenses.License{}, "Contents"),
}, sample.LicenseCmpOpts...)
)