aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/unit_test.go
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-09-01 18:28:33 -0400
committerJulie Qiu <julie@golang.org>2020-09-02 16:44:36 +0000
commitf3921260647d8723941e6a2a43fcd07811ef2dfd (patch)
tree27e1d7449947dbe3becbb687f253f4583a3fd5f6 /internal/postgres/unit_test.go
parentad8f77e99098805b3d7eff12ffc55c63136a55f8 (diff)
downloadgo-x-pkgsite-f3921260647d8723941e6a2a43fcd07811ef2dfd.tar.xz
internal/postgres: add WithLicenses to GetUnit
GetUnit now supports the WithLicenses fieldset, which fetches license contents for the unit. For golang/go#39629 Change-Id: Ic51baf1d36e75c7ad05c59d232f400a756fb7a94 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/252318 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/unit_test.go')
-rw-r--r--internal/postgres/unit_test.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/postgres/unit_test.go b/internal/postgres/unit_test.go
index a5154c8e..d2ffe817 100644
--- a/internal/postgres/unit_test.go
+++ b/internal/postgres/unit_test.go
@@ -363,6 +363,9 @@ func TestGetUnitFieldSet(t *testing.T) {
if fields&internal.WithImports != 0 {
u.Imports = sample.Imports
}
+ if fields&internal.WithLicenses == 0 {
+ u.LicenseContents = nil
+ }
if u.Package != nil {
u.Package.Name = u.Name
}
@@ -386,6 +389,12 @@ func TestGetUnitFieldSet(t *testing.T) {
nil, nil),
},
{
+ name: "WithLicenses",
+ fields: internal.WithLicenses,
+ want: unit("a.com/m/dir/p", "a.com/m", "v1.2.3",
+ nil, nil),
+ },
+ {
name: "WithReadme",
fields: internal.WithReadme,
want: unit("a.com/m/dir/p", "a.com/m", "v1.2.3",
@@ -431,8 +440,9 @@ func unit(path, modulePath, version string, readme *internal.Readme, pkg *intern
IsRedistributable: true,
Licenses: sample.LicenseMetadata,
},
- Readme: readme,
- Package: pkg,
+ LicenseContents: sample.Licenses,
+ Readme: readme,
+ Package: pkg,
}
if pkg != nil {
u.Name = pkg.Name