diff options
| author | Julie Qiu <julie@golang.org> | 2020-04-14 17:55:11 -0400 |
|---|---|---|
| committer | Julie Qiu <julieqiu@google.com> | 2020-04-15 20:33:35 +0000 |
| commit | e90fb1c4adde446b8e963b04e01d8bc4f42a2b2b (patch) | |
| tree | 707907d1e36ad382905f40e03ff9080e39691a1d /internal/testing/sample/sample.go | |
| parent | 8c9ef27613ca4e26c101f2ac2267bed0260b6bd9 (diff) | |
| download | go-x-pkgsite-e90fb1c4adde446b8e963b04e01d8bc4f42a2b2b.tar.xz | |
internal/postgres: insert into paths, readmes, documentation, package_imports
InsertVersion now populates the following tables:
- paths
- readmes
- documentation
- package_imports
Change-Id: Ib02220101d148a261cf55bd564cb9f9a46e60544
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/704882
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/testing/sample/sample.go')
| -rw-r--r-- | internal/testing/sample/sample.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/testing/sample/sample.go b/internal/testing/sample/sample.go index bcec0bf3..9a6a1620 100644 --- a/internal/testing/sample/sample.go +++ b/internal/testing/sample/sample.go @@ -117,6 +117,55 @@ func Module() *internal.Module { ModuleInfo: *ModuleInfo(), Packages: []*internal.Package{Package()}, Licenses: Licenses, + Directories: []*internal.DirectoryNew{ + DirectoryNewForModuleRoot(ModuleInfo(), LicenseMetadata), + DirectoryNewForPackage(Package()), + }, + } +} + +func DirectoryNewEmpty(path string) *internal.DirectoryNew { + return &internal.DirectoryNew{ + Path: path, + IsRedistributable: true, + Licenses: LicenseMetadata, + V1Path: path, + } +} + +func DirectoryNewForModuleRoot(m *internal.ModuleInfo, licenses []*licenses.Metadata) *internal.DirectoryNew { + d := &internal.DirectoryNew{ + Path: m.ModulePath, + IsRedistributable: m.IsRedistributable, + Licenses: licenses, + V1Path: internal.SeriesPathForModule(m.ModulePath), + } + if m.ReadmeFilePath != "" { + d.Readme = &internal.Readme{ + Filepath: m.ReadmeFilePath, + Contents: m.ReadmeContents, + } + } + return d +} + +func DirectoryNewForPackage(pkg *internal.Package) *internal.DirectoryNew { + return &internal.DirectoryNew{ + Path: pkg.Path, + IsRedistributable: pkg.IsRedistributable, + Licenses: pkg.Licenses, + V1Path: pkg.V1Path, + Package: &internal.PackageNew{ + Name: pkg.Name, + Path: pkg.Path, + Imports: pkg.Imports, + Documentation: &internal.Documentation{ + Synopsis: pkg.Synopsis, + HTML: pkg.DocumentationHTML, + GOOS: pkg.GOOS, + GOARCH: pkg.GOARCH, + }, + }, } } |
