adding tests for godo.SetBaseURL() to check BaseURL field and handle parse url errors
This commit is contained in:
parent
3ab73e7c31
commit
a7b77d4c06
21
godo_test.go
21
godo_test.go
|
@ -513,3 +513,24 @@ func TestCustomUserAgent(t *testing.T) {
|
||||||
t.Errorf("New() UserAgent = %s; expected %s", got, expected)
|
t.Errorf("New() UserAgent = %s; expected %s", got, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCustomBaseURL(t *testing.T) {
|
||||||
|
baseURL := "http://localhost/foo"
|
||||||
|
c, err := New(nil, SetBaseURL(baseURL))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("New() unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := baseURL
|
||||||
|
if got := c.BaseURL.String(); got != expected {
|
||||||
|
t.Errorf("New() BaseURL = %s; expected %s", got, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCustomBaseURL_badURL(t *testing.T) {
|
||||||
|
baseURL := ":"
|
||||||
|
_, err := New(nil, SetBaseURL(baseURL))
|
||||||
|
|
||||||
|
testURLParseError(t, err)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue