diff options
| author | Julie Qiu <julie@golang.org> | 2020-10-06 17:25:30 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-10-07 17:46:47 +0000 |
| commit | 3e46543cc11721bcef78cb9eab919bee529e59a9 (patch) | |
| tree | d878a3303f07a84f352f56cce682613c9c5e7f12 /internal/postgres/insert_module_test.go | |
| parent | 8d6417918aaf010bbc79f4d071aea15e0465e559 (diff) | |
| download | go-x-pkgsite-3e46543cc11721bcef78cb9eab919bee529e59a9.tar.xz | |
internal/postgres: update definition of latest
The definition of latest is updated to prefer incompatible
release/prerelease versions over pseudoversion. This matches the
definition by cmd/go.
Change-Id: Ic3c79c32e14dc4df3cf11d52df6548f0fd781a6b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/259997
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/insert_module_test.go')
| -rw-r--r-- | internal/postgres/insert_module_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go index 6a1dd4af..e1652f78 100644 --- a/internal/postgres/insert_module_test.go +++ b/internal/postgres/insert_module_test.go @@ -394,6 +394,51 @@ func TestLatestVersion(t *testing.T) { } } +func TestLatestVersion_PreferIncompatibleOverPrerelease(t *testing.T) { + defer ResetTestDB(testDB, t) + ctx := context.Background() + + for _, mod := range []struct { + version string + modulePath string + }{ + { + version: "v0.0.0-20201007032633-0806396f153e", + modulePath: sample.ModulePath, + }, + { + version: "v2.0.0+incompatible", + modulePath: sample.ModulePath, + }, + } { + m := sample.LegacyDefaultModule() + m.Version = mod.version + m.ModulePath = mod.modulePath + + if err := testDB.InsertModule(ctx, m); err != nil { + t.Fatal(err) + } + } + + for _, tc := range []struct { + modulePath string + want string + }{ + { + modulePath: sample.ModulePath, + want: "v2.0.0+incompatible", + }, + } { + isLatest, err := isLatestVersion(ctx, testDB.db, tc.modulePath, tc.want) + if err != nil { + t.Fatal(err) + } + if !isLatest { + t.Errorf("%s is not the latest version", tc.want) + } + } +} + func TestDeleteModule(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testTimeout) defer cancel() |
