MCPcopy
hub / github.com/kubernetes/client-go / TestInvalidSegments

Function TestInvalidSegments

rest/request_test.go:196–213  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

194}
195
196func TestInvalidSegments(t *testing.T) {
197 invalidSegments := []string{".", "..", "test/segment", "test%2bsegment"}
198 setters := map[string]func(string, *Request){
199 "namespace": func(s string, r *Request) { r.Namespace(s) },
200 "resource": func(s string, r *Request) { r.Resource(s) },
201 "name": func(s string, r *Request) { r.Name(s) },
202 "subresource": func(s string, r *Request) { r.SubResource(s) },
203 }
204 for _, invalidSegment := range invalidSegments {
205 for setterName, setter := range setters {
206 r := &Request{}
207 setter(invalidSegment, r)
208 if r.err == nil {
209 t.Errorf("%s: %s: expected error, got none", setterName, invalidSegment)
210 }
211 }
212 }
213}
214
215func TestRequestParam(t *testing.T) {
216 r := (&Request{}).Param("foo", "a")

Callers

nothing calls this directly

Calls 5

NamespaceMethod · 0.95
ResourceMethod · 0.95
NameMethod · 0.95
SubResourceMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected