aboutsummaryrefslogtreecommitdiff
path: root/plugin/etcd/msg/path_test.go
blob: a20d783335e607faebed2fb714bedb7a62ed8699 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package msg

import "testing"

func TestPath(t *testing.T) {
	for _, path := range []string{"mydns", "skydns"} {
		result := Path("service.staging.skydns.local.", path)
		if result != "/"+path+"/local/skydns/staging/service" {
			t.Errorf("Failure to get domain's path with prefix: %s", result)
		}
	}
}

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)
	}
}