diff options
| author | Julie Qiu <julie@golang.org> | 2020-09-01 18:28:33 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-09-02 16:44:36 +0000 |
| commit | f3921260647d8723941e6a2a43fcd07811ef2dfd (patch) | |
| tree | 27e1d7449947dbe3becbb687f253f4583a3fd5f6 /internal/postgres/insert_module_test.go | |
| parent | ad8f77e99098805b3d7eff12ffc55c63136a55f8 (diff) | |
| download | go-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/insert_module_test.go')
| -rw-r--r-- | internal/postgres/insert_module_test.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go index acaeaee4..fd74d67e 100644 --- a/internal/postgres/insert_module_test.go +++ b/internal/postgres/insert_module_test.go @@ -109,28 +109,28 @@ func checkModule(ctx context.Context, t *testing.T, want *internal.Module) { } } - for _, dir := range want.Units { - got, err := testDB.GetUnit(ctx, &dir.UnitMeta, internal.AllFields) + for _, wantu := range want.Units { + got, err := testDB.GetUnit(ctx, &wantu.UnitMeta, internal.AllFields) if err != nil { t.Fatal(err) } // TODO(golang/go#38513): remove once we start displaying // READMEs for directories instead of the top-level module. - dir.Readme = &internal.Readme{ + wantu.Readme = &internal.Readme{ Filepath: sample.ReadmeFilePath, Contents: sample.ReadmeContents, } - if dir.Package != nil { - dir.Name = dir.Package.Name + wantu.LicenseContents = sample.Licenses + if wantu.Package != nil { + wantu.Name = wantu.Package.Name } - wantd := dir opts := cmp.Options{ cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeFilePath"), cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeContents"), cmpopts.IgnoreFields(licenses.Metadata{}, "Coverage"), cmp.AllowUnexported(source.Info{}, safehtml.HTML{}), } - if diff := cmp.Diff(wantd, got, opts); diff != "" { + if diff := cmp.Diff(wantu, got, opts); diff != "" { t.Errorf("mismatch (-want +got):\n%s", diff) } } |
