From f3921260647d8723941e6a2a43fcd07811ef2dfd Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Tue, 1 Sep 2020 18:28:33 -0400 Subject: 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 TryBot-Result: kokoro Reviewed-by: Jonathan Amsterdam --- internal/postgres/insert_module_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'internal/postgres/insert_module_test.go') 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) } } -- cgit v1.3