diff options
| author | Jonathan Amsterdam <jba@google.com> | 2021-10-14 16:23:30 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2021-10-15 13:50:12 +0000 |
| commit | 76f929b8d02be2754e79e647c4c44b6e69cd0b0c (patch) | |
| tree | e6ad074174bd4858f18f073728f186ec0f877020 /internal/postgres/insert_module_test.go | |
| parent | d5bd14bda078fc2c317cc7405d807a6c492e8d7b (diff) | |
| download | go-x-pkgsite-76f929b8d02be2754e79e647c4c44b6e69cd0b0c.tar.xz | |
internal/{postgres,frontend}: support modules with zero commit times
It's valid to have a module with a zero commit time (as reported by
the proxy .info endpoint). That can happen if the module is served
from a vanity URL with a go-import meta tag of type `mod`.
Process those modules and display them with a publish date of
"unknown."
Fixes golang/go#48952
Change-Id: I8efdebfa27c8b6ed68c183bac77d87ee715f8262
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/356129
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Diffstat (limited to 'internal/postgres/insert_module_test.go')
| -rw-r--r-- | internal/postgres/insert_module_test.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go index 3c44d872..d415dcd5 100644 --- a/internal/postgres/insert_module_test.go +++ b/internal/postgres/insert_module_test.go @@ -77,6 +77,14 @@ func TestInsertModule(t *testing.T) { }(), goMod: "module " + sample.ModulePath + " // Deprecated: use v2", }, + { + name: "zero commit time", + module: func() *internal.Module { + v := sample.DefaultModule() + v.CommitTime = time.Time{} + return v + }(), + }, } { t.Run(test.name, func(t *testing.T) { testDB, release := acquire(t) @@ -259,17 +267,6 @@ func TestInsertModuleErrors(t *testing.T) { wantModulePath: sample.ModulePath, wantWriteErr: derrors.DBModuleInsertInvalid, }, - { - name: "empty commit time", - module: func() *internal.Module { - v := sample.DefaultModule() - v.CommitTime = time.Time{} - return v - }(), - wantVersion: sample.VersionString, - wantModulePath: sample.ModulePath, - wantWriteErr: derrors.BadModule, - }, } for _, test := range testCases { |
