aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/insert_module_test.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2021-04-07 12:43:30 -0400
committerJonathan Amsterdam <jba@google.com>2021-04-07 17:15:13 +0000
commitb3344a7197e09f77cc3b911a8de8b2f69eb0206c (patch)
tree536e21f98a9cb8c22597c03e05350e1697af1f7b /internal/postgres/insert_module_test.go
parent668263d32c7c9b93fd062b90a9081104ae03611e (diff)
downloadgo-x-pkgsite-b3344a7197e09f77cc3b911a8de8b2f69eb0206c.tar.xz
internal/postgres: use MustInsertModuleLatest
For most internal/postgres tests, update latest-version information when we insert a module. That is more like what actually happens on the worker, and some features now rely on it, so we should do it everywhere. Some tests still use a custom go.mod file, so we can't switch to MustInsertModuleLatest for those, because it uses a minimal go.mod file. Change-Id: Ie5030aee4ed9c837931fddb8757e37bf6373a8c7 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/307871 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/postgres/insert_module_test.go')
-rw-r--r--internal/postgres/insert_module_test.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index a5ec926b..66ec5c1d 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -80,9 +80,9 @@ func TestInsertModule(t *testing.T) {
testDB, release := acquire(t)
defer release()
- MustInsertModule(ctx, t, testDB, test.module)
+ MustInsertModuleLatest(ctx, t, testDB, test.module)
// Test that insertion of duplicate primary key won't fail.
- MustInsertModule(ctx, t, testDB, test.module)
+ MustInsertModuleLatest(ctx, t, testDB, test.module)
checkModule(ctx, t, testDB, test.module)
})
}
@@ -158,7 +158,7 @@ func TestInsertModuleLicenseCheck(t *testing.T) {
mod.IsRedistributable = false
mod.Units[0].IsRedistributable = false
- MustInsertModule(ctx, t, db, mod)
+ MustInsertModuleLatest(ctx, t, db, mod)
// New model
u, err := db.GetUnit(ctx, newUnitMeta(mod.ModulePath, mod.ModulePath, mod.Version), internal.AllFields)
@@ -190,7 +190,7 @@ func TestUpsertModule(t *testing.T) {
m := sample.Module("upsert.org", "v1.2.3", "dir/p")
// Insert the module.
- MustInsertModule(ctx, t, testDB, m)
+ MustInsertModuleLatest(ctx, t, testDB, m)
// Change the module, and re-insert.
m.IsRedistributable = !m.IsRedistributable
lic := *m.Licenses[0]
@@ -198,7 +198,7 @@ func TestUpsertModule(t *testing.T) {
sample.ReplaceLicense(m, &lic)
m.Units[0].Readme.Contents += " and more"
- MustInsertModule(ctx, t, testDB, m)
+ MustInsertModuleLatest(ctx, t, testDB, m)
// The changes should have been saved.
checkModule(ctx, t, testDB, m)
}
@@ -303,7 +303,7 @@ func TestInsertModuleNewCoverage(t *testing.T) {
Contents: []byte(`Lorem Ipsum`),
},
}
- MustInsertModule(ctx, t, testDB, m)
+ MustInsertModuleLatest(ctx, t, testDB, m)
u, err := testDB.GetUnit(ctx, newUnitMeta(m.ModulePath, m.ModulePath, m.Version), internal.AllFields)
if err != nil {
t.Fatal(err)
@@ -338,7 +338,7 @@ func TestPostgres_ReadAndWriteModuleOtherColumns(t *testing.T) {
seriesPath: "github.com/user/repo/path",
}
- MustInsertModule(ctx, t, testDB, v)
+ MustInsertModuleLatest(ctx, t, testDB, v)
query := `
SELECT
sort_version, series_path
@@ -450,7 +450,7 @@ func TestDeleteModule(t *testing.T) {
v := sample.DefaultModule()
- MustInsertModule(ctx, t, testDB, v)
+ MustInsertModuleLatest(ctx, t, testDB, v)
if _, err := testDB.GetModuleInfo(ctx, v.ModulePath, v.Version); err != nil {
t.Fatal(err)
}
@@ -513,7 +513,7 @@ func TestPostgres_NewerAlternative(t *testing.T) {
t.Fatal(err)
}
m := sample.Module(mvs.ModulePath, okVersion, "p")
- MustInsertModule(ctx, t, testDB, m)
+ MustInsertModuleLatest(ctx, t, testDB, m)
if _, _, found := GetFromSearchDocuments(ctx, t, testDB, m.Packages()[0].Path); found {
t.Fatal("found package after inserting")
}