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

Function TestDelete

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

Source from the content-addressed store, hash-verified

222}
223
224func TestDelete(t *testing.T) {
225 background := metav1.DeletePropagationBackground
226 uid := types.UID("uid")
227
228 statusOK := &metav1.Status{
229 TypeMeta: metav1.TypeMeta{Kind: "Status"},
230 Status: metav1.StatusSuccess,
231 }
232 tcs := []struct {
233 subresource []string
234 namespace string
235 name string
236 path string
237 deleteOptions *metav1.DeleteOptions
238 }{
239 {
240 name: "normal_delete",
241 path: "/apis/gtest/vtest/rtest/normal_delete",
242 },
243 {
244 namespace: "nstest",
245 name: "namespaced_delete",
246 path: "/apis/gtest/vtest/namespaces/nstest/rtest/namespaced_delete",
247 },
248 {
249 subresource: []string{"srtest"},
250 name: "normal_delete",
251 path: "/apis/gtest/vtest/rtest/normal_delete/srtest",
252 },
253 {
254 subresource: []string{"srtest"},
255 namespace: "nstest",
256 name: "namespaced_delete",
257 path: "/apis/gtest/vtest/namespaces/nstest/rtest/namespaced_delete/srtest",
258 },
259 {
260 namespace: "nstest",
261 name: "namespaced_delete_with_options",
262 path: "/apis/gtest/vtest/namespaces/nstest/rtest/namespaced_delete_with_options",
263 deleteOptions: &metav1.DeleteOptions{Preconditions: &metav1.Preconditions{UID: &uid}, PropagationPolicy: &background},
264 },
265 }
266 for _, tc := range tcs {
267 resource := schema.GroupVersionResource{Group: "gtest", Version: "vtest", Resource: "rtest"}
268 cl, srv, err := getClientServer(func(w http.ResponseWriter, r *http.Request) {
269 if r.Method != "DELETE" {
270 t.Errorf("Delete(%q) got HTTP method %s. wanted DELETE", tc.name, r.Method)
271 }
272
273 if r.URL.Path != tc.path {
274 t.Errorf("Delete(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path)
275 }
276
277 w.Header().Set("Content-Type", runtime.ContentTypeJSON)
278 unstructured.UnstructuredJSONScheme.Encode(statusOK, w)
279 })
280 if err != nil {
281 t.Errorf("unexpected error when creating client: %v", err)

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected