internal/frontend,testing: MustInsertModule -> MustInsertModuleLatest
Update more calls to MustInsertModule to also insert latest-version information.
Change-Id: Ie05212e8f33a6e22fa0ddd87faf393625c4f8b6e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/308070
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/frontend/404_test.go b/internal/frontend/404_test.go
index 6876052..37db6a2 100644
--- a/internal/frontend/404_test.go
+++ b/internal/frontend/404_test.go
@@ -160,7 +160,7 @@
ctx := context.Background()
defer postgres.ResetTestDB(testDB, t)
- postgres.MustInsertModule(ctx, t, testDB, sample.Module(sample.ModulePath+"/v4", "v4.0.0", "foo"))
+ postgres.MustInsertModuleLatest(ctx, t, testDB, sample.Module(sample.ModulePath+"/v4", "v4.0.0", "foo"))
for _, mod := range []struct {
path, version string
diff --git a/internal/frontend/directory_test.go b/internal/frontend/directory_test.go
index 632511a..0d713e5 100644
--- a/internal/frontend/directory_test.go
+++ b/internal/frontend/directory_test.go
@@ -30,7 +30,7 @@
sample.Module("cloud.google.com/go/storage/v9/module", "v9.0.0", sample.Suffix),
sample.Module("cloud.google.com/go/v2", "v2.0.0", "storage", "spanner", "pubsub"),
} {
- postgres.MustInsertModule(ctx, t, testDB, m)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, m)
}
for _, test := range []struct {
diff --git a/internal/frontend/fetch_test.go b/internal/frontend/fetch_test.go
index 4023753..9714e68 100644
--- a/internal/frontend/fetch_test.go
+++ b/internal/frontend/fetch_test.go
@@ -170,7 +170,7 @@
t.Run(strconv.Itoa(test.status), func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), testFetchTimeout)
defer cancel()
- postgres.MustInsertModule(ctx, t, testDB, sample.DefaultModule())
+ postgres.MustInsertModuleLatest(ctx, t, testDB, sample.DefaultModule())
if err := testDB.UpsertVersionMap(ctx, &internal.VersionMap{
ModulePath: sample.ModulePath,
RequestedVersion: sample.VersionString,
diff --git a/internal/frontend/imports_test.go b/internal/frontend/imports_test.go
index bc30011..8f6d0e9 100644
--- a/internal/frontend/imports_test.go
+++ b/internal/frontend/imports_test.go
@@ -54,7 +54,7 @@
pkg := module.Units[1]
pkg.Imports = test.imports
- postgres.MustInsertModule(ctx, t, testDB, module)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, module)
got, err := fetchImportsDetails(ctx, testDB, pkg.Path, pkg.ModulePath, pkg.Version)
if err != nil {
@@ -98,7 +98,7 @@
}
for _, m := range testModules {
- postgres.MustInsertModule(ctx, t, testDB, m)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, m)
}
tests := []struct {
@@ -152,11 +152,11 @@
defer func() { importedByLimit = old }()
m := sample.Module("m.com/a", sample.VersionString, "foo")
- postgres.MustInsertModule(ctx, t, testDB, m)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, m)
for _, mod := range []string{"m1.com/a", "m2.com/a", "m3.com/a"} {
m2 := sample.Module(mod, sample.VersionString, "p")
m2.Packages()[0].Imports = []string{"m.com/a/foo"}
- postgres.MustInsertModule(ctx, t, testDB, m2)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, m2)
}
wantDetails := &ImportedByDetails{
ModulePath: "m.com/a",
diff --git a/internal/frontend/license_test.go b/internal/frontend/license_test.go
index af09140..e7b7699 100644
--- a/internal/frontend/license_test.go
+++ b/internal/frontend/license_test.go
@@ -80,9 +80,9 @@
defer postgres.ResetTestDB(testDB, t)
ctx := context.Background()
- postgres.MustInsertModule(ctx, t, testDB, testModule)
- postgres.MustInsertModule(ctx, t, testDB, stdlibModule)
- postgres.MustInsertModule(ctx, t, testDB, crlfModule)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, testModule)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, stdlibModule)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, crlfModule)
for _, test := range []struct {
err error
name, fullPath, modulePath, version string
diff --git a/internal/frontend/main_test.go b/internal/frontend/main_test.go
index 092c09e..69eea7d 100644
--- a/internal/frontend/main_test.go
+++ b/internal/frontend/main_test.go
@@ -34,7 +34,7 @@
mod2 := newModule(p2, []string{p1}, 1)
mod3 := newModule(p3, []string{p1, p2}, 0)
for _, m := range []*internal.Module{mod1, mod2, mod3} {
- postgres.MustInsertModule(ctx, t, testDB, m)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, m)
}
for _, test := range []struct {
diff --git a/internal/frontend/package_test.go b/internal/frontend/package_test.go
index 1b26cfd..3a8cc8e 100644
--- a/internal/frontend/package_test.go
+++ b/internal/frontend/package_test.go
@@ -21,7 +21,7 @@
"text/template", "html/template", // two matches for "template"
)
ctx := context.Background()
- postgres.MustInsertModule(ctx, t, testDB, m)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, m)
for _, test := range []struct {
path string
diff --git a/internal/frontend/search_test.go b/internal/frontend/search_test.go
index 728013b..55ddf79 100644
--- a/internal/frontend/search_test.go
+++ b/internal/frontend/search_test.go
@@ -94,7 +94,7 @@
}
)
for _, m := range []*internal.Module{moduleFoo, moduleBar} {
- postgres.MustInsertModule(ctx, t, testDB, m)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, m)
}
for _, test := range []struct {
@@ -212,7 +212,7 @@
modules := []*internal.Module{golangTools, std}
for _, v := range modules {
- postgres.MustInsertModule(ctx, t, testDB, v)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, v)
}
for _, test := range []struct {
name string
diff --git a/internal/frontend/server_test.go b/internal/frontend/server_test.go
index 2cfdbf8..2bfe2f6 100644
--- a/internal/frontend/server_test.go
+++ b/internal/frontend/server_test.go
@@ -1248,7 +1248,7 @@
goModPath := "module.path/alternative/pkg"
defer postgres.ResetTestDB(testDB, t)
sampleModule := sample.DefaultModule()
- postgres.MustInsertModule(ctx, t, testDB, sampleModule)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, sampleModule)
alternativeModule := &internal.VersionMap{
ModulePath: altPath,
GoModPath: goModPath,
@@ -1305,7 +1305,7 @@
defer postgres.ResetTestDB(testDB, t)
sampleModule := sample.DefaultModule()
- postgres.MustInsertModule(ctx, t, testDB, sampleModule)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, sampleModule)
alternativeModule := &internal.VersionMap{
ModulePath: "module.path/alternative",
GoModPath: sample.ModulePath,
@@ -1319,7 +1319,7 @@
v1modpath := "notinv1.mod"
v1path := "notinv1.mod/foo"
- postgres.MustInsertModule(ctx, t, testDB, sample.Module(v1modpath+"/v4", "v4.0.0", "foo"))
+ postgres.MustInsertModuleLatest(ctx, t, testDB, sample.Module(v1modpath+"/v4", "v4.0.0", "foo"))
for _, mod := range []struct {
path, version string
status int
@@ -1591,8 +1591,8 @@
defer cancel()
defer postgres.ResetTestDB(testDB, t)
- postgres.MustInsertModule(ctx, t, testDB, sample.Module(sample.ModulePath, sample.VersionString, ""))
- postgres.MustInsertModule(ctx, t, testDB, sample.Module(sample.ModulePath+"/missing/dir/c", sample.VersionString, ""))
+ postgres.MustInsertModuleLatest(ctx, t, testDB, sample.Module(sample.ModulePath, sample.VersionString, ""))
+ postgres.MustInsertModuleLatest(ctx, t, testDB, sample.Module(sample.ModulePath+"/missing/dir/c", sample.VersionString, ""))
missingPath := sample.ModulePath + "/missing"
notInsertedPath := sample.ModulePath + "/missing/dir"
diff --git a/internal/frontend/versions_test.go b/internal/frontend/versions_test.go
index 258ef3e..a3fb633 100644
--- a/internal/frontend/versions_test.go
+++ b/internal/frontend/versions_test.go
@@ -166,7 +166,7 @@
defer postgres.ResetTestDB(testDB, t)
for _, v := range tc.modules {
- postgres.MustInsertModule(ctx, t, testDB, v)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, v)
}
got, err := fetchVersionsDetails(ctx, testDB, tc.pkg.Path, tc.pkg.ModulePath)
diff --git a/internal/testing/integration/frontend_test.go b/internal/testing/integration/frontend_test.go
index 0ccce04..01b9c57 100644
--- a/internal/testing/integration/frontend_test.go
+++ b/internal/testing/integration/frontend_test.go
@@ -103,7 +103,7 @@
if res.Error != nil {
t.Fatal(res.Error)
}
- postgres.MustInsertModule(ctx, t, testDB, res.Module)
+ postgres.MustInsertModuleLatest(ctx, t, testDB, res.Module)
}
func validateResponse(t *testing.T, method, testURL string, wantCode int, wantHTML htmlcheck.Checker) {