diff options
author | 2019-03-05 23:33:22 +0000 | |
---|---|---|
committer | 2019-03-05 15:33:22 -0800 | |
commit | 76224eba02cfb97b18c724d69440b1fc999fccd6 (patch) | |
tree | c3d3140dcb40ebb197827df4a5132e32e918b9e1 /config_test.go | |
parent | e598b4a5dcbe7abf1815677cf0bf6a7983df7cc0 (diff) | |
download | sally-76224eba02cfb97b18c724d69440b1fc999fccd6.tar.gz sally-76224eba02cfb97b18c724d69440b1fc999fccd6.tar.zst sally-76224eba02cfb97b18c724d69440b1fc999fccd6.zip |
Support changing godoc instance (#38)
This adds the ability to change the godoc.org instance used by Sally to
link to documentation by providing a new `godoc` section in the
configuration.
Diffstat (limited to 'config_test.go')
-rw-r--r-- | config_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/config_test.go b/config_test.go index 3bbe7e9..ab1bb2d 100644 --- a/config_test.go +++ b/config_test.go @@ -1,9 +1,11 @@ package main import ( + "fmt" "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestParse(t *testing.T) { @@ -20,6 +22,7 @@ packages: config, err := Parse(path) assert.NoError(t, err) + assert.Equal(t, config.Godoc.Host, "godoc.org") assert.Equal(t, config.URL, "google.golang.org") pkg, ok := config.Packages["grpc"] @@ -28,6 +31,42 @@ packages: assert.Equal(t, pkg, Package{Repo: "github.com/grpc/grpc-go"}) } +func TestParseGodocServer(t *testing.T) { + tests := []struct { + give string + want string + }{ + {"example.com", "example.com"}, + {"example.com/", "example.com"}, + {"http://example.com/", "example.com"}, + {"https://example.com/", "example.com"}, + } + + for _, tt := range tests { + t.Run(tt.give, func(t *testing.T) { + path, clean := TempFile(t, fmt.Sprintf(` +godoc: + host: %q +url: google.golang.org +packages: + grpc: + repo: github.com/grpc/grpc-go +`, tt.give)) + defer clean() + + config, err := Parse(path) + require.NoError(t, err) + + assert.Equal(t, tt.want, config.Godoc.Host) + assert.Equal(t, "google.golang.org", config.URL) + + pkg, ok := config.Packages["grpc"] + assert.True(t, ok) + assert.Equal(t, Package{Repo: "github.com/grpc/grpc-go"}, pkg) + }) + } +} + func TestNotAlphabetical(t *testing.T) { path, clean := TempFile(t, ` |