aboutsummaryrefslogtreecommitdiff
path: root/internal/testing/sample
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-08-31 21:19:41 -0400
committerJulie Qiu <julie@golang.org>2020-09-01 14:40:41 +0000
commita327f4f5ecaffa6d82bfe9cf767b10104c2dcd28 (patch)
tree5d980802ad466f0fa2841f770cd95919855ba0d1 /internal/testing/sample
parent4d4b7bf93903cfc8e05824502b05a2721859f292 (diff)
downloadgo-x-pkgsite-a327f4f5ecaffa6d82bfe9cf767b10104c2dcd28.tar.xz
internal: replace Unit.DirectoryMeta with Unit.PathInfo
Unit.DirectoryMeta is replaced with Unit.PathInfo DirectoryMeta isn't necessary and will be deleted in a future CL. For golang/go#39629 Change-Id: I521a062207d3f48592d6e949306a015458d1398d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/251957 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/sample.go36
1 files changed, 11 insertions, 25 deletions
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go
index bb519696..cf779696 100644
--- a/internal/testing/sample/sample.go
+++ b/internal/testing/sample/sample.go
@@ -116,10 +116,10 @@ func LegacyPackage(modulePath, suffix string) *internal.LegacyPackage {
}
}
-func DirectoryMeta(modulePath, suffix string) *internal.DirectoryMeta {
+func DirectoryMeta(modulePath, suffix, version string) *internal.DirectoryMeta {
p := fullPath(modulePath, suffix)
return &internal.DirectoryMeta{
- ModuleInfo: *ModuleInfo(modulePath, VersionString),
+ ModuleInfo: *ModuleInfo(modulePath, version),
Path: p,
Name: path.Base(p),
IsRedistributable: true,
@@ -198,7 +198,7 @@ func Module(modulePath, version string, suffixes ...string) *internal.Module {
AddPackage(m, lp)
} else {
m.LegacyPackages = append(m.LegacyPackages, lp)
- m.Units[0].Package = UnitForPackage(lp).Package
+ m.Units[0].Package = UnitForPackage(lp, modulePath, version).Package
}
}
return m
@@ -210,7 +210,7 @@ func AddPackage(m *internal.Module, p *internal.LegacyPackage) *internal.Module
p.Path, m.ModulePath))
}
m.LegacyPackages = append(m.LegacyPackages, p)
- AddUnit(m, UnitForPackage(p))
+ AddUnit(m, UnitForPackage(p, m.ModulePath, m.Version))
minLen := len(m.ModulePath)
if m.ModulePath == stdlib.ModulePath {
minLen = 1
@@ -224,7 +224,7 @@ func AddPackage(m *internal.Module, p *internal.LegacyPackage) *internal.Module
}
}
if !found {
- AddUnit(m, UnitEmpty(pth))
+ AddUnit(m, UnitEmpty(pth, m.ModulePath, m.Version))
}
}
return m
@@ -252,24 +252,14 @@ func AddLicense(m *internal.Module, lic *licenses.License) {
}
}
-func UnitEmpty(path string) *internal.Unit {
+func UnitEmpty(path, modulePath, version string) *internal.Unit {
return &internal.Unit{
- DirectoryMeta: internal.DirectoryMeta{
- Path: path,
- IsRedistributable: true,
- Licenses: LicenseMetadata,
- },
+ PathInfo: *PathInfo(path, modulePath, version, "", true),
}
}
func UnitForModuleRoot(m *internal.LegacyModuleInfo, licenses []*licenses.Metadata) *internal.Unit {
- d := &internal.Unit{
- DirectoryMeta: internal.DirectoryMeta{
- Path: m.ModulePath,
- IsRedistributable: m.IsRedistributable,
- Licenses: licenses,
- },
- }
+ d := &internal.Unit{PathInfo: *PathInfo(m.ModulePath, m.ModulePath, m.Version, "", m.IsRedistributable)}
if m.LegacyReadmeFilePath != "" {
d.Readme = &internal.Readme{
Filepath: m.LegacyReadmeFilePath,
@@ -279,14 +269,10 @@ func UnitForModuleRoot(m *internal.LegacyModuleInfo, licenses []*licenses.Metada
return d
}
-func UnitForPackage(pkg *internal.LegacyPackage) *internal.Unit {
+func UnitForPackage(pkg *internal.LegacyPackage, modulePath, version string) *internal.Unit {
return &internal.Unit{
- DirectoryMeta: internal.DirectoryMeta{
- Path: pkg.Path,
- IsRedistributable: pkg.IsRedistributable,
- Licenses: pkg.Licenses,
- },
- Imports: pkg.Imports,
+ PathInfo: *PathInfo(pkg.Path, modulePath, version, pkg.Name, pkg.IsRedistributable),
+ Imports: pkg.Imports,
Package: &internal.Package{
Name: pkg.Name,
Path: pkg.Path,