aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/insert_module_test.go
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-08-31 21:19:41 -0400
committerJulie Qiu <julie@golang.org>2020-09-01 14:40:41 +0000
commita327f4f5ecaffa6d82bfe9cf767b10104c2dcd28 (patch)
tree5d980802ad466f0fa2841f770cd95919855ba0d1 /internal/postgres/insert_module_test.go
parent4d4b7bf93903cfc8e05824502b05a2721859f292 (diff)
downloadgo-x-pkgsite-a327f4f5ecaffa6d82bfe9cf767b10104c2dcd28.tar.xz
internal: replace Unit.DirectoryMeta with Unit.PathInfo
Unit.DirectoryMeta is replaced with Unit.PathInfo DirectoryMeta isn't necessary and will be deleted in a future CL. For golang/go#39629 Change-Id: I521a062207d3f48592d6e949306a015458d1398d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251957 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.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.go15
1 files changed, 3 insertions, 12 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index 482c5975..2b857915 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -41,7 +41,7 @@ func TestInsertModule(t *testing.T) {
},
{
name: "valid test with internal package",
- module: sample.Module(sample.ModulePath, sample.VersionString, "internal/ffoo"),
+ module: sample.Module(sample.ModulePath, sample.VersionString, "internal/foo"),
},
{
name: "valid test with go.mod missing",
@@ -77,7 +77,6 @@ func TestInsertModule(t *testing.T) {
if err := testDB.InsertModule(ctx, test.module); err != nil {
t.Fatal(err)
}
-
checkModule(ctx, t, test.module)
})
}
@@ -111,12 +110,7 @@ func checkModule(ctx context.Context, t *testing.T, want *internal.Module) {
}
for _, dir := range want.Units {
- pathInfo := &internal.PathInfo{
- Path: dir.Path,
- ModulePath: want.ModulePath,
- Version: want.Version,
- }
- got, err := testDB.GetUnit(ctx, pathInfo, internal.AllFields)
+ got, err := testDB.GetUnit(ctx, &dir.PathInfo, internal.AllFields)
if err != nil {
t.Fatal(err)
}
@@ -126,7 +120,6 @@ func checkModule(ctx context.Context, t *testing.T, want *internal.Module) {
Filepath: sample.ReadmeFilePath,
Contents: sample.ReadmeContents,
}
- dir.ModuleInfo = want.ModuleInfo
if dir.Package != nil {
dir.Name = dir.Package.Name
}
@@ -134,12 +127,11 @@ func checkModule(ctx context.Context, t *testing.T, want *internal.Module) {
opts := cmp.Options{
cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeFilePath"),
cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeContents"),
- cmpopts.IgnoreFields(internal.DirectoryMeta{}, "PathID"),
cmpopts.IgnoreFields(licenses.Metadata{}, "Coverage"),
cmp.AllowUnexported(source.Info{}, safehtml.HTML{}),
}
if diff := cmp.Diff(wantd, got, opts); diff != "" {
- t.Errorf("testDB.getDirectory(%q, %q) mismatch (-want +got):\n%s", dir.Path, want.Version, diff)
+ t.Errorf("mismatch (-want +got):\n%s", diff)
}
}
}
@@ -240,7 +232,6 @@ func TestUpsertModule(t *testing.T) {
if err := testDB.InsertModule(ctx, m); err != nil {
t.Fatal(err)
}
-
// The changes should have been saved.
checkModule(ctx, t, m)
}