internal/postgres: rename LegacyGetModuleLicenses to getModuleLicenses
For golang/go#39629
Change-Id: I7c81258bbffeb35ca0b158e46a18a7395d6abd17
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258284
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/internal/postgres/insert_module.go b/internal/postgres/insert_module.go
index 3191d08..a6de5c8 100644
--- a/internal/postgres/insert_module.go
+++ b/internal/postgres/insert_module.go
@@ -639,7 +639,7 @@
// are licenses in the licenses table that are not present in m.Licenses.
func (db *DB) compareLicenses(ctx context.Context, m *internal.Module) (err error) {
defer derrors.Wrap(&err, "compareLicenses(ctx, %q, %q)", m.ModulePath, m.Version)
- dbLicenses, err := db.LegacyGetModuleLicenses(ctx, m.ModulePath, m.Version)
+ dbLicenses, err := db.getModuleLicenses(ctx, m.ModulePath, m.Version)
if err != nil {
return err
}
diff --git a/internal/postgres/licenses.go b/internal/postgres/licenses.go
index 6ca9d14..0629917 100644
--- a/internal/postgres/licenses.go
+++ b/internal/postgres/licenses.go
@@ -90,11 +90,11 @@
return lics, nil
}
-// LegacyGetModuleLicenses returns all licenses associated with the given module path and
+// getModuleLicenses returns all licenses associated with the given module path and
// version. These are the top-level licenses in the module zip file.
// It returns an InvalidArgument error if the module path or version is invalid.
-func (db *DB) LegacyGetModuleLicenses(ctx context.Context, modulePath, resolvedVersion string) (_ []*licenses.License, err error) {
- defer derrors.Wrap(&err, "LegacyGetModuleLicenses(ctx, %q, %q)", modulePath, resolvedVersion)
+func (db *DB) getModuleLicenses(ctx context.Context, modulePath, resolvedVersion string) (_ []*licenses.License, err error) {
+ defer derrors.Wrap(&err, "getModuleLicenses(ctx, %q, %q)", modulePath, resolvedVersion)
if modulePath == "" || resolvedVersion == "" {
return nil, fmt.Errorf("neither modulePath nor version can be empty: %w", derrors.InvalidArgument)
diff --git a/internal/postgres/licenses_test.go b/internal/postgres/licenses_test.go
index 584aed1..5c41df9 100644
--- a/internal/postgres/licenses_test.go
+++ b/internal/postgres/licenses_test.go
@@ -125,7 +125,7 @@
}
}
-func TestLegacyGetModuleLicenses(t *testing.T) {
+func TestGetModuleLicenses(t *testing.T) {
modulePath := "test.module"
testModule := sample.Module(modulePath, "v1.2.3", "", "foo", "bar")
testModule.LegacyPackages[0].Licenses = []*licenses.Metadata{{Types: []string{"ISC"}, FilePath: "LICENSE"}}
@@ -148,14 +148,14 @@
t.Fatal(err)
}
- got, err := testDB.LegacyGetModuleLicenses(ctx, modulePath, testModule.Version)
+ got, err := testDB.getModuleLicenses(ctx, modulePath, testModule.Version)
if err != nil {
t.Fatal(err)
}
// We only want the top-level license.
wantLicenses := []*licenses.License{testModule.Licenses[0]}
if diff := cmp.Diff(wantLicenses, got); diff != "" {
- t.Errorf("testDB.LegacyGetModuleLicenses(ctx, %q, %q) mismatch (-want +got):\n%s", modulePath, testModule.Version, diff)
+ t.Errorf("testDB.getModuleLicenses(ctx, %q, %q) mismatch (-want +got):\n%s", modulePath, testModule.Version, diff)
}
}
@@ -224,7 +224,7 @@
var lics []*licenses.License
var err error
if legacy {
- lics, err = db.LegacyGetModuleLicenses(ctx, sample.ModulePath, m.Version)
+ lics, err = db.getModuleLicenses(ctx, sample.ModulePath, m.Version)
} else {
lics, err = db.LegacyGetLicenses(ctx, sample.ModulePath, sample.ModulePath, m.Version)
}