internal/postgres: replace LegacyPackage in insert_module_test.go
For golang/go#39629
Change-Id: I8b2f8eda2035ad121abd01922f1938f9e0db5caa
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/263202
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index e1652f7..dc1182e 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -19,7 +19,6 @@
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/safehtml"
- "github.com/google/safehtml/testconversions"
"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/database"
"golang.org/x/pkgsite/internal/derrors"
@@ -54,19 +53,8 @@
}(),
},
{
- name: "stdlib",
- module: func() *internal.Module {
- m := sample.LegacyModule("std", "v1.12.5")
- p := &internal.LegacyPackage{
- Name: "context",
- Path: "context",
- Synopsis: "This is a package synopsis",
- Licenses: sample.LicenseMetadata,
- IsRedistributable: true,
- DocumentationHTML: testconversions.MakeHTMLForTest("This is the documentation HTML"),
- }
- return sample.LegacyAddPackage(m, p)
- }(),
+ name: "stdlib",
+ module: sample.LegacyModule("std", "v1.12.5", "context"),
},
} {
t.Run(test.name, func(t *testing.T) {
@@ -149,7 +137,6 @@
mod := sample.LegacyModule(sample.ModulePath, sample.VersionString, "")
checkHasRedistData(mod.Units[0].Readme.Contents, mod.Units[0].Documentation.HTML, true)
mod.IsRedistributable = false
- mod.LegacyPackages[0].IsRedistributable = false
mod.Units[0].IsRedistributable = false
if err := db.InsertModule(ctx, mod); err != nil {
@@ -182,16 +169,7 @@
func TestUpsertModule(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel()
- m := sample.LegacyModule("upsert.org", "v1.2.3")
- p := &internal.LegacyPackage{
- Name: "p",
- Path: "upsert.org/dir/p",
- Synopsis: "This is a package synopsis",
- Licenses: sample.LicenseMetadata,
- IsRedistributable: true,
- DocumentationHTML: testconversions.MakeHTMLForTest("This is the documentation HTML"),
- }
- sample.LegacyAddPackage(m, p)
+ m := sample.LegacyModule("upsert.org", "v1.2.3", "dir/p")
// Insert the module.
if err := testDB.InsertModule(ctx, m); err != nil {
@@ -203,7 +181,7 @@
// TODO(golang/go#38513): uncomment line below once we start displaying
// READMEs for directories instead of the top-level module.
// m.Units[0].Readme.Contents += " and more"
- m.LegacyPackages[0].Synopsis = "New synopsis"
+
if err := testDB.InsertModule(ctx, m); err != nil {
t.Fatal(err)
}
@@ -505,7 +483,7 @@
if err := testDB.InsertModule(ctx, m); err != nil {
t.Fatal(err)
}
- if _, _, found := GetFromSearchDocuments(ctx, t, testDB, m.LegacyPackages[0].Path); found {
+ if _, _, found := GetFromSearchDocuments(ctx, t, testDB, m.Packages()[0].Path); found {
t.Fatal("found package after inserting")
}
}