diff options
| author | Julie Qiu <julie@golang.org> | 2019-06-07 13:44:54 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2020-03-27 16:46:38 -0400 |
| commit | a1f1c569a42fd542d662bc3aaa9cb529f9ec3bfa (patch) | |
| tree | 06b6ee5501e855548e0948ff351380962cb1739f /internal/postgres/postgres_test.go | |
| parent | 6b8229f9d83671201443e2d0968da4823837e02b (diff) | |
| download | go-x-pkgsite-a1f1c569a42fd542d662bc3aaa9cb529f9ec3bfa.tar.xz | |
content,internal: add support for standard library packages
The Go standard library packages are now supported on the discovery
site, under the module "std".
It is also now possible to make fetch requests to the cron for module
versions using a tag or commit hash.
The versions template is also updated based on the current mock.
Updates b/131859847
Updates b/132875076
Updates b/126597197
Change-Id: I01fbbbff5bfec93d0ee4c5048f98ffe2da2f2a6a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/472904
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'internal/postgres/postgres_test.go')
| -rw-r--r-- | internal/postgres/postgres_test.go | 89 |
1 files changed, 56 insertions, 33 deletions
diff --git a/internal/postgres/postgres_test.go b/internal/postgres/postgres_test.go index 5b3d02df..33c178b6 100644 --- a/internal/postgres/postgres_test.go +++ b/internal/postgres/postgres_test.go @@ -299,6 +299,24 @@ func TestPostgres_ReadAndWriteVersionAndPackages(t *testing.T) { wantWriteErrType: derrors.InvalidArgumentType, wantReadErr: true, }, + { + name: "stdlib", + version: sampleVersion(func(v *internal.Version) { + v.ModulePath = "std" + v.SeriesPath = "std" + v.Version = "v1.12.5" + v.Packages = []*internal.Package{{ + Name: "context", + Path: "context", + Synopsis: "This is a package synopsis", + Licenses: sampleLicenseInfos, + DocumentationHTML: []byte("This is the documentation HTML"), + }} + }), + getModule: "std", + getVersion: "v1.12.5", + getPkg: "context", + }, } for _, tc := range testCases { @@ -898,53 +916,58 @@ func TestPostgres_GetTaggedAndPseudoVersionsForPackageSeries(t *testing.T) { } } -func TestMajorMinorPatch(t *testing.T) { +func TestExtractSemverParts(t *testing.T) { for _, tc := range []struct { - version string + version, wantPrerelease string wantMajor, wantMinor, wantPatch int }{ { - version: "v1.5.2", - wantMajor: 1, - wantMinor: 5, - wantPatch: 2, + version: "v1.5.2", + wantMajor: 1, + wantMinor: 5, + wantPatch: 2, + wantPrerelease: "~", + }, + { + version: "v1.5.2", + wantMajor: 1, + wantMinor: 5, + wantPatch: 2, + wantPrerelease: "~", + }, + { + version: "v1.5.2+incompatible", + wantMajor: 1, + wantMinor: 5, + wantPatch: 2, + wantPrerelease: "~", }, { - version: "v1.5.2+incompatible", - wantMajor: 1, - wantMinor: 5, - wantPatch: 2, + version: "v1.5.2-alpha+buildtag", + wantMajor: 1, + wantMinor: 5, + wantPatch: 2, + wantPrerelease: "alpha", }, { - version: "v1.5.2-alpha+buildtag", - wantMajor: 1, - wantMinor: 5, - wantPatch: 2, + version: "v1.5.2-alpha.1+buildtag", + wantMajor: 1, + wantMinor: 5, + wantPatch: 2, + wantPrerelease: "alpha.00000000000000000001", }, } { t.Run(tc.version, func(t *testing.T) { - gotMajor, err := major(tc.version) - if err != nil { - t.Errorf("major(%q): %v", tc.version, err) - } - if gotMajor != tc.wantMajor { - t.Errorf("major(%q) = %d, want = %d", tc.version, gotMajor, tc.wantMajor) - } - - gotMinor, err := minor(tc.version) - if err != nil { - t.Errorf("minor(%q): %v", tc.version, err) - } - if gotMinor != tc.wantMinor { - t.Errorf("minor(%q) = %d, want = %d", tc.version, gotMinor, tc.wantMinor) - } + gotMajor, gotMinor, gotPatch, gotPrerelease, err := extractSemverParts(tc.version) - gotPatch, err := patch(tc.version) if err != nil { - t.Errorf("patch(%q): %v", tc.version, err) + t.Errorf("extractSemverParts(%q): %v", tc.version, err) } - if gotPatch != tc.wantPatch { - t.Errorf("patch(%q) = %d, want = %d", tc.version, gotPatch, tc.wantPatch) + if gotMajor != tc.wantMajor || + gotMinor != tc.wantMinor || + gotPatch != tc.wantPatch || + gotPrerelease != tc.wantPrerelease { + t.Errorf("extractSemverParts(%q) = %d, %d, %d, %q; want = %d, %d, %d, %q", tc.version, gotMajor, gotMinor, gotPatch, gotPrerelease, tc.wantMajor, tc.wantMinor, tc.wantPatch, tc.wantPrerelease) } }) } |
