internal/frontend: add test for nested module to TestServer
A test is added for a path that is both a directory and a nested module
(cloud.google.com/pubsublite).
Change-Id: Ie2db548d0a89664ead1942deb877548a04c9551b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/277698
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>
diff --git a/internal/frontend/server_test.go b/internal/frontend/server_test.go
index bc7a692..6e8c390 100644
--- a/internal/frontend/server_test.go
+++ b/internal/frontend/server_test.go
@@ -249,6 +249,28 @@
},
},
},
+ {
+ path: "cloud.google.com/go",
+ redistributable: true,
+ versions: []string{"v0.69.0"},
+ packages: []testPackage{
+ {
+ name: "pubsublite",
+ suffix: "pubsublite",
+ },
+ },
+ },
+ {
+ path: "cloud.google.com/go/pubsublite",
+ redistributable: true,
+ versions: []string{"v0.4.0"},
+ packages: []testPackage{
+ {
+ name: "pubsublite",
+ suffix: "",
+ },
+ },
+ },
}
func insertTestModules(ctx context.Context, t *testing.T, mods []testModule) {
@@ -503,6 +525,37 @@
LatestMajorVersionLink: "/net/http",
}
+ pubsubliteDir := &pagecheck.Page{
+ ModulePath: "cloud.google.com/go",
+ ModuleURL: "cloud.google.com/go",
+ Title: "pubsublite",
+ Suffix: "pubsublite",
+ Version: "v0.69.0",
+ FormattedVersion: "v0.69.0",
+ LicenseType: "MIT",
+ LicenseFilePath: "LICENSE",
+ IsLatestMinor: true,
+ IsLatestMajor: true,
+ UnitURLFormat: "/cloud.google.com/go%s/pubsublite",
+ LatestLink: "/cloud.google.com/go/pubsublite",
+ LatestMajorVersionLink: "/cloud.google.com/go/pubsublite",
+ }
+
+ pubsubliteMod := &pagecheck.Page{
+ ModulePath: "cloud.google.com/go/pubsublite",
+ Title: "pubsublite",
+ ModuleURL: "cloud.google.com/go/pubsublite",
+ Version: "v0.4.0",
+ FormattedVersion: "v0.4.0",
+ LicenseType: "MIT",
+ LicenseFilePath: "LICENSE",
+ IsLatestMinor: true,
+ IsLatestMajor: true,
+ UnitURLFormat: "/cloud.google.com/go/pubsublite%s",
+ LatestLink: "/cloud.google.com/go/pubsublite",
+ LatestMajorVersionLink: "/cloud.google.com/go/pubsublite",
+ }
+
return []serverTestCase{
{
name: "C",
@@ -843,6 +896,27 @@
want: in("",
pagecheck.LicenseDetails("MIT", "Lorem Ipsum", "go.googlesource.com/go/+/refs/tags/go1.13/LICENSE")),
},
+ {
+ name: "pubsublite unversioned",
+ urlPath: "/cloud.google.com/go/pubsublite",
+ wantStatusCode: http.StatusOK,
+ want: in("",
+ pagecheck.UnitHeader(pubsubliteDir, unversioned, isPackage)),
+ },
+ {
+ name: "pubsublite module",
+ urlPath: "/cloud.google.com/go/pubsublite@v0.4.0",
+ wantStatusCode: http.StatusOK,
+ want: in("",
+ pagecheck.UnitHeader(pubsubliteMod, versioned, isPackage)),
+ },
+ {
+ name: "pubsublite directory",
+ urlPath: "/cloud.google.com/go@v0.69.0/pubsublite",
+ wantStatusCode: http.StatusOK,
+ want: in("",
+ pagecheck.UnitHeader(pubsubliteDir, versioned, isDirectory)),
+ },
}
}