diff options
author | 2016-10-12 11:04:26 -0700 | |
---|---|---|
committer | 2016-10-12 11:04:26 -0700 | |
commit | ac8374fd17e30fca9a7773a2a6f690a7ea4d2ec9 (patch) | |
tree | e9a61adde4bc5eef80583f3e1d6f9379a20b4f99 /handler_test.go | |
parent | b80c4f3e920994823061eb05dc0a5bc3881ddb02 (diff) | |
download | sally-ac8374fd17e30fca9a7773a2a6f690a7ea4d2ec9.tar.gz sally-ac8374fd17e30fca9a7773a2a6f690a7ea4d2ec9.tar.zst sally-ac8374fd17e30fca9a7773a2a6f690a7ea4d2ec9.zip |
Rework as HTTP server (#15)
Diffstat (limited to 'handler_test.go')
-rw-r--r-- | handler_test.go | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/handler_test.go b/handler_test.go new file mode 100644 index 0000000..9f2eca8 --- /dev/null +++ b/handler_test.go @@ -0,0 +1,102 @@ +package main + +import "testing" + +var config = ` + +url: go.uber.org +packages: + yarpc: + repo: github.com/yarpc/yarpc-go + thriftrw: + repo: github.com/thriftrw/thriftrw-go + +` + +func TestIndex(t *testing.T) { + rr := CallAndRecord(t, config, "/") + AssertResponse(t, rr, 200, ` +<!DOCTYPE html> +<html> + <body> + <ul> + <li>thriftrw - github.com/thriftrw/thriftrw-go</li> + <li>yarpc - github.com/yarpc/yarpc-go</li> + </ul> + </body> +</html> +`) +} + +func TestPackageShouldExist(t *testing.T) { + rr := CallAndRecord(t, config, "/yarpc") + AssertResponse(t, rr, 200, ` +<!DOCTYPE html> +<html> + <head> + <meta name="go-import" content="go.uber.org/yarpc git https://github.com/yarpc/yarpc-go"> + <meta name="go-source" content="go.uber.org/yarpc https://github.com/yarpc/yarpc-go https://github.com/yarpc/yarpc-go/tree/master{/dir} https://github.com/yarpc/yarpc-go/tree/master{/dir}/{file}#L{line}"> + <meta http-equiv="refresh" content="0; url=https://godoc.org/go.uber.org/yarpc"> + </head> + <body> + Nothing to see here. Please <a href="https://godoc.org/go.uber.org/yarpc">move along</a>. + </body> +</html> +`) +} + +func TestNonExistentPackageShould404(t *testing.T) { + rr := CallAndRecord(t, config, "/nonexistent") + AssertResponse(t, rr, 404, ` +404 page not found +`) +} + +func TestTrailingSlash(t *testing.T) { + rr := CallAndRecord(t, config, "/yarpc/") + AssertResponse(t, rr, 200, ` +<!DOCTYPE html> +<html> + <head> + <meta name="go-import" content="go.uber.org/yarpc git https://github.com/yarpc/yarpc-go"> + <meta name="go-source" content="go.uber.org/yarpc https://github.com/yarpc/yarpc-go https://github.com/yarpc/yarpc-go/tree/master{/dir} https://github.com/yarpc/yarpc-go/tree/master{/dir}/{file}#L{line}"> + <meta http-equiv="refresh" content="0; url=https://godoc.org/go.uber.org/yarpc/"> + </head> + <body> + Nothing to see here. Please <a href="https://godoc.org/go.uber.org/yarpc/">move along</a>. + </body> +</html> +`) +} + +func TestDeepImports(t *testing.T) { + rr := CallAndRecord(t, config, "/yarpc/heeheehee") + AssertResponse(t, rr, 200, ` +<!DOCTYPE html> +<html> + <head> + <meta name="go-import" content="go.uber.org/yarpc git https://github.com/yarpc/yarpc-go"> + <meta name="go-source" content="go.uber.org/yarpc https://github.com/yarpc/yarpc-go https://github.com/yarpc/yarpc-go/tree/master{/dir} https://github.com/yarpc/yarpc-go/tree/master{/dir}/{file}#L{line}"> + <meta http-equiv="refresh" content="0; url=https://godoc.org/go.uber.org/yarpc/heeheehee"> + </head> + <body> + Nothing to see here. Please <a href="https://godoc.org/go.uber.org/yarpc/heeheehee">move along</a>. + </body> +</html> +`) + + rr = CallAndRecord(t, config, "/yarpc/heehee/hawhaw") + AssertResponse(t, rr, 200, ` +<!DOCTYPE html> +<html> + <head> + <meta name="go-import" content="go.uber.org/yarpc git https://github.com/yarpc/yarpc-go"> + <meta name="go-source" content="go.uber.org/yarpc https://github.com/yarpc/yarpc-go https://github.com/yarpc/yarpc-go/tree/master{/dir} https://github.com/yarpc/yarpc-go/tree/master{/dir}/{file}#L{line}"> + <meta http-equiv="refresh" content="0; url=https://godoc.org/go.uber.org/yarpc/heehee/hawhaw"> + </head> + <body> + Nothing to see here. Please <a href="https://godoc.org/go.uber.org/yarpc/heehee/hawhaw">move along</a>. + </body> +</html> +`) +} |