diff options
| author | Jonathan Amsterdam <jba@google.com> | 2021-02-24 19:32:06 -0500 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2021-02-25 04:10:49 +0000 |
| commit | c058e1b3b9543e940a799326801ff67d8b6bc790 (patch) | |
| tree | b9e9d60d2a93a5fa8956f8429a6952aab22ed41a /internal/postgres/unit_test.go | |
| parent | 25c6b92f3b602125029d927673ada6a99c3e2c7f (diff) | |
| download | go-x-pkgsite-c058e1b3b9543e940a799326801ff67d8b6bc790.tar.xz | |
internal/postgres: add retraction/deprecation info to GetUnitMeta
For golang/go#43265
For golang/go#41321
Change-Id: I8dc86d87882b96d3c3ffe7c1d035937f210b9a91
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296229
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/postgres/unit_test.go')
| -rw-r--r-- | internal/postgres/unit_test.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/internal/postgres/unit_test.go b/internal/postgres/unit_test.go index 7c867f67..79d00111 100644 --- a/internal/postgres/unit_test.go +++ b/internal/postgres/unit_test.go @@ -27,6 +27,7 @@ func TestGetUnitMeta(t *testing.T) { defer release() ctx, cancel := context.WithTimeout(context.Background(), testTimeout) defer cancel() + ctx = experiment.NewContext(ctx, internal.ExperimentRetractions) for _, testModule := range []struct { module, version, packageSuffix string @@ -59,6 +60,8 @@ func TestGetUnitMeta(t *testing.T) { } } + addRawLatest(ctx, t, testDB, "m.com", "v.1.1.0", "module m.com\nretract v1.0.1 // bad") + type teststruct struct { name string path, module, version string @@ -136,7 +139,12 @@ func TestGetUnitMeta(t *testing.T) { { name: "directory", path: "m.com/dir", - want: wantUnitMeta("m.com", "v1.0.1", ""), + want: func() *internal.UnitMeta { + um := wantUnitMeta("m.com", "v1.0.1", "") + um.Retracted = true + um.RetractionRationale = "bad" + return um + }(), }, { name: "module at master version", @@ -174,14 +182,17 @@ func TestGetUnitMeta(t *testing.T) { if test.version == "" { test.version = internal.LatestVersion } - test.want = sample.UnitMeta( + want := sample.UnitMeta( test.path, test.want.ModulePath, test.want.Version, test.want.Name, test.want.IsRedistributable, ) - test.want.CommitTime = sample.CommitTime + want.CommitTime = sample.CommitTime + want.Retracted = test.want.Retracted + want.RetractionRationale = test.want.RetractionRationale + test.want = want checkUnitMeta(ctx, test) }) } |
