Adds some locality stuff

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2020-01-24 13:34:59 +01:00
parent eaa7f0d6eb
commit 2d14fa270b
6 changed files with 86 additions and 25 deletions

View File

@@ -49,3 +49,32 @@ func TestParseTraffic(t *testing.T) {
}
}
}
func testParseLocality(t *testing.T) {
s := "region"
locs, err := parseLocality(s)
if err != nil {
t.Fatal(err)
}
if locs[0].Region != "region" {
t.Errorf("Expected %s, but got %s", "region", locs[0].Region)
}
s = "region1,zone,sub region2"
locs, err = parseLocality(s)
if err != nil {
t.Fatal(err)
}
if locs[0].Zone != "zone" {
t.Errorf("Expected %s, but got %s", "zone", locs[1].Zone)
}
if locs[0].SubZone != "sub" {
t.Errorf("Expected %s, but got %s", "sub", locs[1].SubZone)
}
if locs[1].Region != "region2" {
t.Errorf("Expected %s, but got %s", "region2", locs[1].Region)
}
if locs[1].Zone != "" {
t.Errorf("Expected %s, but got %s", "", locs[1].Zone)
}
}