MCPcopy
hub / github.com/kubernetes/kubectl / TestDeleteFlagValidation

Function TestDeleteFlagValidation

pkg/cmd/delete/delete_test.go:52–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestDeleteFlagValidation(t *testing.T) {
53 f := cmdtesting.NewTestFactory()
54 defer f.Cleanup()
55
56 tests := []struct {
57 flags DeleteFlags
58 args [][]string
59 expectedErr string
60 }{
61 {
62 flags: DeleteFlags{
63 Raw: ptr.To("test"),
64 Interactive: ptr.To(true),
65 },
66 expectedErr: "--interactive can not be used with --raw",
67 },
68 }
69
70 for _, test := range tests {
71 cmd := fakecmd()
72 deleteOptions, err := test.flags.ToOptions(nil, genericiooptions.NewTestIOStreamsDiscard())
73 if err != nil {
74 t.Fatalf("unexpected error creating delete options: %s", err)
75 }
76 deleteOptions.Filenames = []string{"../../../testdata/redis-master-controller.yaml"}
77 err = deleteOptions.Complete(f, nil, cmd)
78 if err != nil {
79 t.Fatalf("unexpected error creating delete options: %s", err)
80 }
81 err = deleteOptions.Validate()
82 if err == nil {
83 t.Fatalf("missing expected error")
84 }
85 if test.expectedErr != err.Error() {
86 t.Errorf("expected error %s, got %s", test.expectedErr, err)
87 }
88 }
89}
90
91func TestDeleteObjectByTuple(t *testing.T) {
92 cmdtesting.InitTestErrorHandler(t)

Callers

nothing calls this directly

Calls 7

CleanupMethod · 0.95
fakecmdFunction · 0.85
ToMethod · 0.80
ToOptionsMethod · 0.45
CompleteMethod · 0.45
ValidateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…