From d6c70eec19f84ba2f0531a37db5d030073da504a Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Tue, 1 Sep 2020 23:03:56 -0400 Subject: internal: add WithSubdirectories support to GetUnit GetUnit now returns the subdirectories for that unit, when the WithSubdirectories fieldset is provided. For golang/go#39629 Change-Id: I3976cfec67bc70fc2d532583f2ab2d2af14eada1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/252401 Run-TryBot: Julie Qiu TryBot-Result: kokoro Reviewed-by: Jonathan Amsterdam --- internal/postgres/insert_module_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (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 49f0552a..b1f8c406 100644 --- a/internal/postgres/insert_module_test.go +++ b/internal/postgres/insert_module_test.go @@ -11,6 +11,7 @@ import ( "fmt" "io/ioutil" "path/filepath" + "strings" "sync" "testing" "time" @@ -24,6 +25,7 @@ import ( "golang.org/x/pkgsite/internal/derrors" "golang.org/x/pkgsite/internal/licenses" "golang.org/x/pkgsite/internal/source" + "golang.org/x/pkgsite/internal/stdlib" "golang.org/x/pkgsite/internal/testing/sample" ) @@ -121,6 +123,14 @@ func checkModule(ctx context.Context, t *testing.T, want *internal.Module) { Contents: sample.ReadmeContents, } wantu.LicenseContents = sample.Licenses + var subdirectories []*internal.PackageMeta + for _, u := range want.Units { + if u.IsPackage() && (strings.HasPrefix(u.Path, wantu.Path) || + wantu.Path == stdlib.ModulePath) { + subdirectories = append(subdirectories, sample.PackageMeta(u.Path)) + } + } + wantu.Subdirectories = subdirectories opts := cmp.Options{ cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeFilePath"), cmpopts.IgnoreFields(internal.LegacyModuleInfo{}, "LegacyReadmeContents"), -- cgit v1.3-6-g1900