Add unit test for namespace aware proxy

This commit is contained in:
derekwaynecarr
2014-10-20 16:25:08 -04:00
parent 71c6f8ee5c
commit 51aeb6bcd1
2 changed files with 19 additions and 10 deletions

View File

@@ -132,15 +132,17 @@ func TestProxyTransport_fixLinks(t *testing.T) {
func TestProxy(t *testing.T) {
table := []struct {
method string
path string
reqBody string
respBody string
method string
path string
reqBody string
respBody string
reqNamespace string
}{
{"GET", "/some/dir", "", "answer"},
{"POST", "/some/other/dir", "question", "answer"},
{"PUT", "/some/dir/id", "different question", "answer"},
{"DELETE", "/some/dir/id", "", "ok"},
{"GET", "/some/dir", "", "answer", "default"},
{"POST", "/some/other/dir", "question", "answer", "default"},
{"PUT", "/some/dir/id", "different question", "answer", "default"},
{"DELETE", "/some/dir/id", "", "ok", "default"},
{"GET", "/some/dir/id?namespace=other", "", "answer", "other"},
}
for _, item := range table {
@@ -156,8 +158,9 @@ func TestProxy(t *testing.T) {
}))
simpleStorage := &SimpleRESTStorage{
errors: map[string]error{},
resourceLocation: proxyServer.URL,
errors: map[string]error{},
resourceLocation: proxyServer.URL,
expectedResourceNamespace: item.reqNamespace,
}
handler := Handle(map[string]RESTStorage{
"foo": simpleStorage,