From 0bc1ff74086152ceed1b7b3a4ef1ea26ce26f787 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 7 Aug 2017 14:45:30 -0700 Subject: mw/kubernetes: autopath refactors (#850) Factor out as much of autopath into a subpackage as possible right now. apw.Sent is not needed, we should see this from the rcode returned by the middleware. See #852 on why this was needed. Disable the tests for now as to not break the main build. --- middleware/kubernetes/autopath/autopath_test.go | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 middleware/kubernetes/autopath/autopath_test.go (limited to 'middleware/kubernetes/autopath/autopath_test.go') diff --git a/middleware/kubernetes/autopath/autopath_test.go b/middleware/kubernetes/autopath/autopath_test.go new file mode 100644 index 000000000..787896e42 --- /dev/null +++ b/middleware/kubernetes/autopath/autopath_test.go @@ -0,0 +1,26 @@ +package autopath + +import "testing" + +func TestSplitSearchPath(t *testing.T) { + type testCase struct { + question string + namespace string + expectedName string + expectedSearch string + expectedOk bool + } + tests := []testCase{ + {question: "test.blah.com", namespace: "ns1", expectedName: "", expectedSearch: "", expectedOk: false}, + {question: "foo.com.ns2.svc.interwebs.nets", namespace: "ns1", expectedName: "", expectedSearch: "", expectedOk: false}, + {question: "foo.com.svc.interwebs.nets", namespace: "ns1", expectedName: "", expectedSearch: "", expectedOk: false}, + {question: "foo.com.ns1.svc.interwebs.nets", namespace: "ns1", expectedName: "foo.com", expectedSearch: "ns1.svc.interwebs.nets", expectedOk: true}, + } + zone := "interwebs.nets" + for _, c := range tests { + name, search, ok := SplitSearch(zone, c.question, c.namespace) + if c.expectedName != name || c.expectedSearch != search || c.expectedOk != ok { + t.Errorf("Case %v: Expected name'%v', search:'%v', ok:'%v'. Got name:'%v', search:'%v', ok:'%v'.", c.question, c.expectedName, c.expectedSearch, c.expectedOk, name, search, ok) + } + } +} -- cgit v1.2.3