aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-12-14 11:33:51 -0500
committerJulie Qiu <julie@golang.org>2020-12-14 16:50:45 +0000
commitbd852dc5f13bca63f031a69b7482a3a7c6729698 (patch)
treeb21acab2daba8299469a0b48d09ef7f8c15c4dc0 /internal/postgres
parent4e306af91274b1f7cd0d186347da1d7bbf941edb (diff)
downloadgo-x-pkgsite-bd852dc5f13bca63f031a69b7482a3a7c6729698.tar.xz
internal/frontend: fix commitTime for tests
CL 268638 added `.In(time.UTC)` to the commitTime for several tests. This was causing tests to fail when run locally, due to different outputs of absoluteTime. absoluteTime for these commit times are now computed within the tests. sample.UnitMeta also now sets the CommitTime to NowTruncated(). Change-Id: I3187c9a5eacd5d136c73080b2803241cb2022729 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/271808 Trust: Julie Qiu <julie@golang.org> 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')
-rw-r--r--internal/postgres/unit_test.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/postgres/unit_test.go b/internal/postgres/unit_test.go
index 72255e74..3ac4539a 100644
--- a/internal/postgres/unit_test.go
+++ b/internal/postgres/unit_test.go
@@ -160,6 +160,7 @@ func TestGetUnit(t *testing.T) {
test.want.Name,
test.want.IsRedistributable,
)
+ test.want.CommitTime = um.CommitTime
checkUnit(ctx, t, um, test.want)
})
}
@@ -180,8 +181,7 @@ func checkUnit(ctx context.Context, t *testing.T, um *internal.UnitMeta, want *i
want.SourceInfo = um.SourceInfo
want.NumImports = len(want.Imports)
opts = append(opts,
- cmpopts.IgnoreFields(internal.Unit{}, "Imports"),
- cmpopts.IgnoreFields(internal.Unit{}, "LicenseContents"),
+ cmpopts.IgnoreFields(internal.Unit{}, "Imports", "LicenseContents"),
)
if diff := cmp.Diff(want, got, opts...); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
@@ -252,14 +252,14 @@ func TestGetUnitFieldSet(t *testing.T) {
},
} {
t.Run(test.name, func(t *testing.T) {
- pathInfo := sample.UnitMeta(
+ um := sample.UnitMeta(
test.want.Path,
test.want.ModulePath,
test.want.Version,
test.want.Name,
test.want.IsRedistributable,
)
- got, err := testDB.GetUnit(ctx, pathInfo, test.fields)
+ got, err := testDB.GetUnit(ctx, um, test.fields)
if err != nil {
t.Fatal(err)
}
@@ -268,7 +268,8 @@ func TestGetUnitFieldSet(t *testing.T) {
// The packages table only includes partial license information; it omits the Coverage field.
cmpopts.IgnoreFields(licenses.Metadata{}, "Coverage"),
}
- test.want.SourceInfo = pathInfo.SourceInfo
+ test.want.CommitTime = um.CommitTime
+ test.want.SourceInfo = um.SourceInfo
cleanFields(test.want, test.fields)
if diff := cmp.Diff(test.want, got, opts...); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)