aboutsummaryrefslogtreecommitdiff
path: root/handler_test.go
diff options
context:
space:
mode:
authorGravatar Tyler Sullivan <sullivtr@gmail.com> 2022-01-03 16:36:17 -0800
committerGravatar GitHub <noreply@github.com> 2022-01-03 16:36:17 -0800
commit8a0c579592136da8105d54081c3f69060c4dcf71 (patch)
treee9a54b6e9ca5fc1f6d31af3e3bd23abafce43218 /handler_test.go
parentdd62ebd406a23184ec072d38894a5a3aac141b0d (diff)
downloadsally-8a0c579592136da8105d54081c3f69060c4dcf71.tar.gz
sally-8a0c579592136da8105d54081c3f69060c4dcf71.tar.zst
sally-8a0c579592136da8105d54081c3f69060c4dcf71.zip
Support package-level overrides for URLs (#52)
Sally accepts the base vanity URL (e.g. `go.uber.org`) in a top-level `url` key. This applies to all packages listed in the configuration. Add support for overriding the `url` on a per-package basis. This will provide for an easier transition period when migrating Go packages of an organization between hosts, for example from BitBucket to GitHub. With this, source code can be modified across the various repositories over time to use the new vanity URL. For example, some packages will use a URL of bitbucketurl.org and some will use mycoolgoimportvanity.org in their source code imports. Other than the use-case outlined above, this feature adds flexibility to the vanity server to support more than one vanity URL when used behind an ingress controller.
Diffstat (limited to 'handler_test.go')
-rw-r--r--handler_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/handler_test.go b/handler_test.go
index 978f62d..96a10dd 100644
--- a/handler_test.go
+++ b/handler_test.go
@@ -14,6 +14,9 @@ packages:
repo: github.com/thriftrw/thriftrw-go
yarpc:
repo: github.com/yarpc/yarpc-go
+ zap:
+ url: go.uberalt.org
+ repo: github.com/uber-go/zap
`
@@ -98,3 +101,20 @@ func TestDeepImports(t *testing.T) {
</html>
`)
}
+
+func TestPackageLevelURL(t *testing.T) {
+ rr := CallAndRecord(t, config, "/zap")
+ AssertResponse(t, rr, 200, `
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="go-import" content="go.uberalt.org/zap git https://github.com/uber-go/zap">
+ <meta name="go-source" content="go.uberalt.org/zap https://github.com/uber-go/zap https://github.com/uber-go/zap/tree/master{/dir} https://github.com/uber-go/zap/tree/master{/dir}/{file}#L{line}">
+ <meta http-equiv="refresh" content="0; url=https://pkg.go.dev/go.uberalt.org/zap">
+ </head>
+ <body>
+ Nothing to see here. Please <a href="https://pkg.go.dev/go.uberalt.org/zap">move along</a>.
+ </body>
+</html>
+`)
+}