mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
@@ -9,7 +9,7 @@ import (
|
||||
func TestSetup(t *testing.T) {
|
||||
c := caddy.NewTestController("dns", `traffic grpc://127.0.0.1`)
|
||||
if err := setup(c); err != nil {
|
||||
t.Fatalf("Test 1, expected no errors, but got: %q", err)
|
||||
t.Fatalf("Expected no errors, but got: %q", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ func TestParseTraffic(t *testing.T) {
|
||||
c := caddy.NewTestController("dns", test.input)
|
||||
_, err := parseTraffic(c)
|
||||
if test.shouldErr && err == nil {
|
||||
t.Errorf("Test %v: Expected error but found nil", i)
|
||||
t.Errorf("Test %d: Expected error, but got: nil", i)
|
||||
continue
|
||||
} else if !test.shouldErr && err != nil {
|
||||
t.Errorf("Test %v: Expected no error but found error: %v", i, err)
|
||||
t.Errorf("Test %d: Expected no error, but got: %v", i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -49,32 +49,3 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user