forked from davecheney/godoc2md
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main_test.go
30 lines (28 loc) · 1.27 KB
/
main_test.go
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
package main
import (
"testing"
)
func TestUrlFromPackage(t *testing.T) {
testData := []struct {
pkg string
expected string
}{
{"github.com/davecheney/godoc2md", "https://github.com/davecheney/godoc2md/tree/master"},
{"github.com/davecheney/godoc2md/examples", "https://github.com/davecheney/godoc2md/tree/master/examples"},
{"github.com/davecheney/godoc2md/examples/martini", "https://github.com/davecheney/godoc2md/tree/master/examples/martini"},
{"bitbucket.org/atlassianlabs/bitbucket-golang-base", "https://bitbucket.org/atlassianlabs/bitbucket-golang-base/src/master"},
{"bitbucket.org/atlassianlabs/bitbucket-golang-base/util", "https://bitbucket.org/atlassianlabs/bitbucket-golang-base/src/master/util"},
{"time", "https://golang.org/src/time"},
{"go/build", "https://golang.org/src/go/build"},
{"go/build/build.go", "https://golang.org/src/go/build/build.go"},
{"encoding/json", "https://golang.org/src/encoding/json"},
{"golang.org/x/tools/godoc", "https://github.com/golang/tools/tree/master/godoc"},
{"example.com/myuser/myrepo", "https://example.com/myuser/myrepo/src"},
}
for n, tt := range testData {
got := urlFromPackage(tt.pkg)
if got != tt.expected {
t.Errorf("urlFromPackage(%d): expected %s, got %s", n, tt.expected, got)
}
}
}