1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
var config = `
url: go.uber.org
packages:
thriftrw:
repo: github.com/thriftrw/thriftrw-go
yarpc:
repo: github.com/yarpc/yarpc-go
zap:
url: go.uberalt.org
repo: github.com/uber-go/zap
description: A fast, structured logging library.
`
func TestIndex(t *testing.T) {
rr := CallAndRecord(t, config, "/")
assert.Equal(t, 200, rr.Code)
body := rr.Body.String()
assert.Contains(t, body, "github.com/thriftrw/thriftrw-go")
assert.Contains(t, body, "github.com/yarpc/yarpc-go")
assert.Contains(t, body, "A fast, structured logging library.")
}
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://pkg.go.dev/go.uber.org/yarpc">
</head>
<body>
Nothing to see here. Please <a href="https://pkg.go.dev/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://pkg.go.dev/go.uber.org/yarpc/">
</head>
<body>
Nothing to see here. Please <a href="https://pkg.go.dev/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://pkg.go.dev/go.uber.org/yarpc/heeheehee">
</head>
<body>
Nothing to see here. Please <a href="https://pkg.go.dev/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://pkg.go.dev/go.uber.org/yarpc/heehee/hawhaw">
</head>
<body>
Nothing to see here. Please <a href="https://pkg.go.dev/go.uber.org/yarpc/heehee/hawhaw">move along</a>.
</body>
</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>
`)
}
|