aboutsummaryrefslogtreecommitdiff
path: root/internal/testing/sample/sample.go
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-08-25 17:48:46 -0400
committerJulie Qiu <julie@golang.org>2020-08-26 14:04:02 +0000
commit4e17962c9d72701baaa8cd94a53cb21cf6bf87b2 (patch)
tree404f663a393090a88624f7c7b65f56e89d411276 /internal/testing/sample/sample.go
parentb420ef11c677003f7ebd734a88c8a680206e1065 (diff)
downloadgo-x-pkgsite-4e17962c9d72701baaa8cd94a53cb21cf6bf87b2.tar.xz
internal/testing/sample: fix sample DirectoryMeta
Missing fields on sample.DirectoryMeta are added. For golang/go#39629 Change-Id: Iec69dea44fee12aa97eea9f8e1ba7d7cb3e2ada3 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/250547 Reviewed-by: Jonathan Amsterdam <jba@google.com> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/testing/sample/sample.go')
-rw-r--r--internal/testing/sample/sample.go35
1 files changed, 22 insertions, 13 deletions
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go
index 5a9abf4f..f9585b41 100644
--- a/internal/testing/sample/sample.go
+++ b/internal/testing/sample/sample.go
@@ -96,13 +96,9 @@ func NowTruncated() time.Time {
//
// The package name is last component of the package path.
func LegacyPackage(modulePath, suffix string) *internal.LegacyPackage {
- pkgPath := suffix
- if modulePath != stdlib.ModulePath {
- pkgPath = path.Join(modulePath, suffix)
- }
return &internal.LegacyPackage{
- Name: path.Base(pkgPath),
- Path: pkgPath,
+ Name: path.Base(fullPath(modulePath, suffix)),
+ Path: fullPath(modulePath, suffix),
V1Path: internal.V1Path(modulePath, suffix),
Synopsis: Synopsis,
IsRedistributable: true,
@@ -114,17 +110,23 @@ func LegacyPackage(modulePath, suffix string) *internal.LegacyPackage {
}
}
-func PackageMeta(modulePath, suffix string) *internal.PackageMeta {
- pkgPath := suffix
- if modulePath != stdlib.ModulePath {
- pkgPath = path.Join(modulePath, suffix)
+func DirectoryMeta(modulePath, suffix string) *internal.DirectoryMeta {
+ return &internal.DirectoryMeta{
+ ModuleInfo: *ModuleInfo(modulePath, VersionString),
+ Path: fullPath(modulePath, suffix),
+ V1Path: internal.V1Path(modulePath, suffix),
+ IsRedistributable: true,
+ Licenses: LicenseMetadata,
}
+}
+
+func PackageMeta(modulePath, suffix string) *internal.PackageMeta {
return &internal.PackageMeta{
- Path: pkgPath,
+ Path: fullPath(modulePath, suffix),
IsRedistributable: true,
- Licenses: LicenseMetadata,
- Name: path.Base(pkgPath),
+ Name: path.Base(fullPath(modulePath, suffix)),
Synopsis: Synopsis,
+ Licenses: LicenseMetadata,
}
}
@@ -304,3 +306,10 @@ func DirectoryForPackage(pkg *internal.LegacyPackage) *internal.Directory {
},
}
}
+
+func fullPath(modulePath, suffix string) string {
+ if modulePath != stdlib.ModulePath {
+ return path.Join(modulePath, suffix)
+ }
+ return suffix
+}