(t *testing.T)
| 281 | } |
| 282 | |
| 283 | func TestDeleteCollection(t *testing.T) { |
| 284 | statusOK := &metav1.Status{ |
| 285 | TypeMeta: metav1.TypeMeta{Kind: "Status"}, |
| 286 | Status: metav1.StatusSuccess, |
| 287 | } |
| 288 | tcs := []struct { |
| 289 | namespace string |
| 290 | name string |
| 291 | path string |
| 292 | }{ |
| 293 | { |
| 294 | name: "normal_delete_collection", |
| 295 | path: "/apis/gtest/vtest/rtest", |
| 296 | }, |
| 297 | { |
| 298 | namespace: "nstest", |
| 299 | name: "namespaced_delete_collection", |
| 300 | path: "/apis/gtest/vtest/namespaces/nstest/rtest", |
| 301 | }, |
| 302 | } |
| 303 | for _, tc := range tcs { |
| 304 | gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"} |
| 305 | resource := &metav1.APIResource{Name: "rtest", Namespaced: len(tc.namespace) != 0} |
| 306 | cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) { |
| 307 | if r.Method != "DELETE" { |
| 308 | t.Errorf("DeleteCollection(%q) got HTTP method %s. wanted DELETE", tc.name, r.Method) |
| 309 | } |
| 310 | |
| 311 | if r.URL.Path != tc.path { |
| 312 | t.Errorf("DeleteCollection(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path) |
| 313 | } |
| 314 | |
| 315 | w.Header().Set("Content-Type", runtime.ContentTypeJSON) |
| 316 | unstructured.UnstructuredJSONScheme.Encode(statusOK, w) |
| 317 | }) |
| 318 | if err != nil { |
| 319 | t.Errorf("unexpected error when creating client: %v", err) |
| 320 | continue |
| 321 | } |
| 322 | defer srv.Close() |
| 323 | |
| 324 | err = cl.Resource(resource, tc.namespace).DeleteCollection(nil, metav1.ListOptions{}) |
| 325 | if err != nil { |
| 326 | t.Errorf("unexpected error when deleting collection %q: %v", tc.name, err) |
| 327 | continue |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | func TestCreate(t *testing.T) { |
| 333 | tcs := []struct { |
nothing calls this directly
no test coverage detected