(t *testing.T)
| 292 | } |
| 293 | |
| 294 | func 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 | |
| 342 | func TestCreate(t *testing.T) { |
| 343 | tcs := []struct { |
nothing calls this directly
no test coverage detected