remote: Test HTTP validation
This commit is contained in:
parent
02d8df93e4
commit
c1ecdd1e3d
|
@ -34,6 +34,9 @@ func (c *HTTPRemoteClient) validateConfig(conf map[string]string) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to parse url: %v", err)
|
||||
}
|
||||
if url.Scheme != "http" && url.Scheme != "https" {
|
||||
return fmt.Errorf("invalid url: %s", url)
|
||||
}
|
||||
c.url = url
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -19,6 +19,23 @@ func TestHTTPRemote_Interface(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHTTPRemote_Validate(t *testing.T) {
|
||||
conf := map[string]string{}
|
||||
if _, err := NewHTTPRemoteClient(conf); err == nil {
|
||||
t.Fatalf("expect error")
|
||||
}
|
||||
|
||||
conf["url"] = ""
|
||||
if _, err := NewHTTPRemoteClient(conf); err == nil {
|
||||
t.Fatalf("expect error")
|
||||
}
|
||||
|
||||
conf["url"] = "http://cool.com"
|
||||
if _, err := NewHTTPRemoteClient(conf); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPRemote_GetState(t *testing.T) {
|
||||
type tcase struct {
|
||||
Code int
|
||||
|
|
Loading…
Reference in New Issue