2016-02-20 21:05:48 +00:00
|
|
|
package rest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func parseURL(s string) *url.URL {
|
|
|
|
u, err := url.Parse(s)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return u
|
|
|
|
}
|
|
|
|
|
|
|
|
var configTests = []struct {
|
|
|
|
s string
|
|
|
|
cfg Config
|
|
|
|
}{
|
|
|
|
{"rest:http://localhost:1234", Config{
|
2017-06-05 22:25:22 +00:00
|
|
|
URL: parseURL("http://localhost:1234"),
|
2017-06-11 11:46:54 +00:00
|
|
|
Connections: 5,
|
2016-02-20 21:05:48 +00:00
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseConfig(t *testing.T) {
|
|
|
|
for i, test := range configTests {
|
|
|
|
cfg, err := ParseConfig(test.s)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("test %d:%s failed: %v", i, test.s, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(cfg, test.cfg) {
|
|
|
|
t.Errorf("test %d:\ninput:\n %s\n wrong config, want:\n %v\ngot:\n %v",
|
|
|
|
i, test.s, test.cfg, cfg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|