From d667981893663f883b0349d5fe9332fdde296cc0 Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Mon, 8 Jun 2020 11:28:48 -0400 Subject: 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 Reviewed-by: Jonathan Amsterdam --- internal/postgres/insert_module_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'internal/postgres/insert_module_test.go') 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") } } -- cgit v1.3-6-g1900