diff options
| author | Julie Qiu <julie@golang.org> | 2020-09-01 23:03:56 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-09-02 17:14:50 +0000 |
| commit | d6c70eec19f84ba2f0531a37db5d030073da504a (patch) | |
| tree | 532af6c2916bbd8d19b24763d28f7b25b7fbc6d9 /internal/postgres/insert_module_test.go | |
| parent | b795075c291073a479c9c50a8815516eb650d785 (diff) | |
| download | go-x-pkgsite-d6c70eec19f84ba2f0531a37db5d030073da504a.tar.xz | |
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 <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 | 10 |
1 files changed, 10 insertions, 0 deletions
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"), |
