fix: convert key to domain (#5064)

fix convert key to domain when key ends with '/'
This commit is contained in:
soulfy
2022-02-01 22:45:43 +08:00
committed by GitHub
parent 6377e6a9d9
commit 49ee97994e
2 changed files with 15 additions and 0 deletions

View File

@@ -10,3 +10,15 @@ func TestPath(t *testing.T) {
}
}
}
func TestDomain(t *testing.T) {
result1 := Domain("/skydns/local/cluster/staging/service/")
if result1 != "service.staging.cluster.local." {
t.Errorf("Failure to get domain from etcd key (with a trailing '/'), expect: 'service.staging.cluster.local.', actually get: '%s'", result1)
}
result2 := Domain("/skydns/local/cluster/staging/service")
if result2 != "service.staging.cluster.local." {
t.Errorf("Failure to get domain from etcd key (without trailing '/'), expect: 'service.staging.cluster.local.' actually get: '%s'", result2)
}
}