mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
pkg/types: Add tests for NewURLsMapFromStringMap
This commit is contained in:
parent
17e23769d9
commit
d41ce0a97c
@ -112,3 +112,44 @@ func TestNewURLsMapIPV6(t *testing.T) {
|
|||||||
t.Errorf("cluster = %#v, want %#v", c, wc)
|
t.Errorf("cluster = %#v, want %#v", c, wc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewURLsMapFromStringMapEmpty(t *testing.T) {
|
||||||
|
mss := make(map[string]string)
|
||||||
|
urlsMap, err := NewURLsMapFromStringMap(mss, ",")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
s := ""
|
||||||
|
um, err := NewURLsMap(s)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if um.String() != urlsMap.String() {
|
||||||
|
t.Errorf("Expected:\n%+v\ngot:\n%+v", um, urlsMap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewURLsMapFromStringMapNormal(t *testing.T) {
|
||||||
|
mss := make(map[string]string)
|
||||||
|
mss["host0"] = "http://127.0.0.1:2379,http://127.0.0.1:2380"
|
||||||
|
mss["host1"] = "http://127.0.0.1:2381,http://127.0.0.1:2382"
|
||||||
|
mss["host2"] = "http://127.0.0.1:2383,http://127.0.0.1:2384"
|
||||||
|
mss["host3"] = "http://127.0.0.1:2385,http://127.0.0.1:2386"
|
||||||
|
urlsMap, err := NewURLsMapFromStringMap(mss, ",")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
s := "host0=http://127.0.0.1:2379,host0=http://127.0.0.1:2380," +
|
||||||
|
"host1=http://127.0.0.1:2381,host1=http://127.0.0.1:2382," +
|
||||||
|
"host2=http://127.0.0.1:2383,host2=http://127.0.0.1:2384," +
|
||||||
|
"host3=http://127.0.0.1:2385,host3=http://127.0.0.1:2386"
|
||||||
|
um, err := NewURLsMap(s)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if um.String() != urlsMap.String() {
|
||||||
|
t.Errorf("Expected:\n%+v\ngot:\n%+v", um, urlsMap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user