Support SubResource call on Request
Allows better semantic use of Request when dealing with sub resources, and allows clients to ignore ordering. Supports multiple segments because sub-resources are less tightly structured than regular resources.
This commit is contained in:
@@ -129,6 +129,16 @@ func TestRequestOrdersNamespaceInPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestOrdersSubResource(t *testing.T) {
|
||||
r := (&Request{
|
||||
baseURL: &url.URL{},
|
||||
path: "/test/",
|
||||
}).Name("bar").Resource("baz").Namespace("foo").Suffix("test").SubResource("a", "b")
|
||||
if s := r.finalURL(); s != "/test/namespaces/foo/baz/bar/a/b/test" {
|
||||
t.Errorf("namespace should be in order in path: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestSetTwiceError(t *testing.T) {
|
||||
if (&Request{}).Name("bar").Name("baz").err == nil {
|
||||
t.Errorf("setting name twice should result in error")
|
||||
@@ -139,6 +149,9 @@ func TestRequestSetTwiceError(t *testing.T) {
|
||||
if (&Request{}).Resource("bar").Resource("baz").err == nil {
|
||||
t.Errorf("setting resource twice should result in error")
|
||||
}
|
||||
if (&Request{}).SubResource("bar").SubResource("baz").err == nil {
|
||||
t.Errorf("setting subresource twice should result in error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestParseSelectorParam(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user