aboutsummaryrefslogtreecommitdiff
path: root/internal/testing/sample
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-10-25 23:09:27 -0400
committerJulie Qiu <julie@golang.org>2020-10-26 13:06:03 +0000
commitb218e2462cb2e0bfd7ea31593ca4eede9b8e92a6 (patch)
tree3ece1dfcd563212c07cf7413ddfcda5a1fd72452 /internal/testing/sample
parent3d386cf767db883bd6701692d79caedc6a148427 (diff)
downloadgo-x-pkgsite-b218e2462cb2e0bfd7ea31593ca4eede9b8e92a6.tar.xz
internal/testing/sample: move all structs to sample.go
There are no more legacy functions remaining. All functions are moved to sample.go and legacy.go is deleted. For golang/go#39629 Change-Id: I54789bfd8db5713105a574e08143e272b08bafb6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/265007 Trust: Julie Qiu <julie@golang.org> 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/testing/sample')
-rw-r--r--internal/testing/sample/legacy.go53
-rw-r--r--internal/testing/sample/sample.go40
2 files changed, 40 insertions, 53 deletions
diff --git a/internal/testing/sample/legacy.go b/internal/testing/sample/legacy.go
deleted file mode 100644
index 3c79d255..00000000
--- a/internal/testing/sample/legacy.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package sample provides functionality for generating sample values of
-// the types contained in the internal package.
-package sample
-
-import (
- "path"
-
- "golang.org/x/pkgsite/internal"
-)
-
-func DefaultModule() *internal.Module {
- fp := constructFullPath(ModulePath, Suffix)
- return AddPackage(Module(ModulePath, VersionString), UnitForPackage(fp, ModulePath, VersionString, path.Base(fp), true))
-}
-
-// Module creates a Module with the given path and version.
-// The list of suffixes is used to create Units within the module.
-func Module(modulePath, version string, suffixes ...string) *internal.Module {
- mi := ModuleInfo(modulePath, version)
- m := &internal.Module{
- ModuleInfo: *mi,
- Licenses: Licenses,
- }
- m.Units = []*internal.Unit{UnitForModuleRoot(mi)}
- for _, s := range suffixes {
- fp := constructFullPath(modulePath, s)
- lp := UnitForPackage(fp, modulePath, VersionString, path.Base(fp), m.IsRedistributable)
- if s != "" {
- AddPackage(m, lp)
- } else {
- u := UnitForPackage(lp.Path, modulePath, version, lp.Name, lp.IsRedistributable)
- m.Units[0].Documentation = u.Documentation
- m.Units[0].Name = u.Name
- }
- }
- return m
-}
-
-func UnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit {
- u := &internal.Unit{
- UnitMeta: *UnitMeta(m.ModulePath, m.ModulePath, m.Version, "", m.IsRedistributable),
- LicenseContents: Licenses,
- }
- u.Readme = &internal.Readme{
- Filepath: ReadmeFilePath,
- Contents: ReadmeContents,
- }
- return u
-}
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go
index b0a16068..144ce29b 100644
--- a/internal/testing/sample/sample.go
+++ b/internal/testing/sample/sample.go
@@ -93,6 +93,46 @@ func NowTruncated() time.Time {
return time.Now().Truncate(time.Microsecond)
}
+func DefaultModule() *internal.Module {
+ fp := constructFullPath(ModulePath, Suffix)
+ return AddPackage(Module(ModulePath, VersionString), UnitForPackage(fp, ModulePath, VersionString, path.Base(fp), true))
+}
+
+// Module creates a Module with the given path and version.
+// The list of suffixes is used to create Units within the module.
+func Module(modulePath, version string, suffixes ...string) *internal.Module {
+ mi := ModuleInfo(modulePath, version)
+ m := &internal.Module{
+ ModuleInfo: *mi,
+ Licenses: Licenses,
+ }
+ m.Units = []*internal.Unit{UnitForModuleRoot(mi)}
+ for _, s := range suffixes {
+ fp := constructFullPath(modulePath, s)
+ lp := UnitForPackage(fp, modulePath, VersionString, path.Base(fp), m.IsRedistributable)
+ if s != "" {
+ AddPackage(m, lp)
+ } else {
+ u := UnitForPackage(lp.Path, modulePath, version, lp.Name, lp.IsRedistributable)
+ m.Units[0].Documentation = u.Documentation
+ m.Units[0].Name = u.Name
+ }
+ }
+ return m
+}
+
+func UnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit {
+ u := &internal.Unit{
+ UnitMeta: *UnitMeta(m.ModulePath, m.ModulePath, m.Version, "", m.IsRedistributable),
+ LicenseContents: Licenses,
+ }
+ u.Readme = &internal.Readme{
+ Filepath: ReadmeFilePath,
+ Contents: ReadmeContents,
+ }
+ return u
+}
+
// UnitForPackage constructs a unit with the given module path and suffix.
//
// If modulePath is the standard library, the package path is the