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

Function TestDeleteCollection

dynamic/client_test.go:294–340  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

292}
293
294func TestDeleteCollection(t *testing.T) {
295 statusOK := &metav1.Status{
296 TypeMeta: metav1.TypeMeta{Kind: "Status"},
297 Status: metav1.StatusSuccess,
298 }
299 tcs := []struct {
300 namespace string
301 name string
302 path string
303 }{
304 {
305 name: "normal_delete_collection",
306 path: "/apis/gtest/vtest/rtest",
307 },
308 {
309 namespace: "nstest",
310 name: "namespaced_delete_collection",
311 path: "/apis/gtest/vtest/namespaces/nstest/rtest",
312 },
313 }
314 for _, tc := range tcs {
315 resource := schema.GroupVersionResource{Group: "gtest", Version: "vtest", Resource: "rtest"}
316 cl, srv, err := getClientServer(func(w http.ResponseWriter, r *http.Request) {
317 if r.Method != "DELETE" {
318 t.Errorf("DeleteCollection(%q) got HTTP method %s. wanted DELETE", tc.name, r.Method)
319 }
320
321 if r.URL.Path != tc.path {
322 t.Errorf("DeleteCollection(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path)
323 }
324
325 w.Header().Set("Content-Type", runtime.ContentTypeJSON)
326 unstructured.UnstructuredJSONScheme.Encode(statusOK, w)
327 })
328 if err != nil {
329 t.Errorf("unexpected error when creating client: %v", err)
330 continue
331 }
332 defer srv.Close()
333
334 err = cl.Resource(resource).Namespace(tc.namespace).DeleteCollection(nil, metav1.ListOptions{})
335 if err != nil {
336 t.Errorf("unexpected error when deleting collection %q: %v", tc.name, err)
337 continue
338 }
339 }
340}
341
342func TestCreate(t *testing.T) {
343 tcs := []struct {

Callers

nothing calls this directly

Calls 8

getClientServerFunction · 0.70
ErrorfMethod · 0.65
SetMethod · 0.65
CloseMethod · 0.65
DeleteCollectionMethod · 0.65
NamespaceMethod · 0.65
ResourceMethod · 0.65
EncodeMethod · 0.45

Tested by

no test coverage detected