aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/insert_module_test.go
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-06-08 11:28:48 -0400
committerJulie Qiu <julieqiu@google.com>2020-06-08 20:24:07 +0000
commitd667981893663f883b0349d5fe9332fdde296cc0 (patch)
treea7d8c6ab304c04597256c3dcdede414a9c18b53e /internal/postgres/insert_module_test.go
parent3914aa0bd477239a44ea89a226b3d02dda8bb08f (diff)
downloadgo-x-pkgsite-d667981893663f883b0349d5fe9332fdde296cc0.tar.xz
internal: prefix legacy structs with Legacy
The following structs have been renamed with a Legacy prefix: * internal.Directory * internal.Package * internal.VersionedPackage * sample.Package The following fields on internal.ModuleInfo have also been changed: * ReadmeFilePath * ReadmeFileContents This is done to help us distinguish between legacy and method structs/methods while migrating code to the new data model. Change-Id: Ibedf71d4db6323ef5aa05d73a0240537ea6073d3 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/765160 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/postgres/insert_module_test.go')
-rw-r--r--internal/postgres/insert_module_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index 59ffbfe4..99a5bf02 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -62,7 +62,7 @@ func TestInsertModule(t *testing.T) {
name: "stdlib",
module: func() *internal.Module {
m := sample.Module("std", "v1.12.5")
- p := &internal.Package{
+ p := &internal.LegacyPackage{
Name: "context",
Path: "context",
Synopsis: "This is a package synopsis",
@@ -92,7 +92,7 @@ func TestInsertModule(t *testing.T) {
t.Fatalf("testDB.GetModuleInfo(%q, %q) mismatch (-want +got):\n%s", test.module.ModulePath, test.module.Version, diff)
}
- for _, want := range test.module.Packages {
+ for _, want := range test.module.LegacyPackages {
got, err := testDB.GetPackage(ctx, want.Path, test.module.ModulePath, test.module.Version)
if err != nil {
t.Fatal(err)
@@ -101,11 +101,11 @@ func TestInsertModule(t *testing.T) {
// The packages table only includes partial
// license information; it omits the Coverage
// field.
- cmpopts.IgnoreFields(internal.Package{}, "Imports"),
+ cmpopts.IgnoreFields(internal.LegacyPackage{}, "Imports"),
cmpopts.IgnoreFields(licenses.Metadata{}, "Coverage"),
cmpopts.EquateEmpty(),
}
- if diff := cmp.Diff(*want, got.Package, opts...); diff != "" {
+ if diff := cmp.Diff(*want, got.LegacyPackage, opts...); diff != "" {
t.Fatalf("testDB.GetPackage(%q, %q) mismatch (-want +got):\n%s", want.Path, test.module.Version, diff)
}
@@ -121,8 +121,8 @@ func TestInsertModule(t *testing.T) {
ModuleInfo: test.module.ModuleInfo,
}
opts := cmp.Options{
- cmpopts.IgnoreFields(internal.ModuleInfo{}, "ReadmeFilePath"),
- cmpopts.IgnoreFields(internal.ModuleInfo{}, "ReadmeContents"),
+ cmpopts.IgnoreFields(internal.ModuleInfo{}, "LegacyReadmeFilePath"),
+ cmpopts.IgnoreFields(internal.ModuleInfo{}, "LegacyReadmeContents"),
cmpopts.IgnoreFields(licenses.Metadata{}, "Coverage"),
cmp.AllowUnexported(source.Info{}),
}
@@ -294,7 +294,7 @@ func TestPostgres_NewerAlternative(t *testing.T) {
if err := testDB.InsertModule(ctx, m); err != nil {
t.Fatal(err)
}
- if _, _, found := GetFromSearchDocuments(ctx, t, testDB, m.Packages[0].Path); found {
+ if _, _, found := GetFromSearchDocuments(ctx, t, testDB, m.LegacyPackages[0].Path); found {
t.Fatal("found package after inserting")
}
}