MCPcopy
hub / github.com/vmware-tanzu/sonobuoy / TestDeleteInvalidConfig

Function TestDeleteInvalidConfig

pkg/client/delete_test.go:26–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestDeleteInvalidConfig(t *testing.T) {
27 testcases := []struct {
28 desc string
29 config *DeleteConfig
30 expectedErrorMsg string
31 }{
32 {
33 desc: "Passing a nil config results in an error",
34 config: nil,
35 expectedErrorMsg: "nil DeleteConfig provided",
36 },
37 {
38 desc: "Passing an invalid config with an empty namespace results in an error",
39 config: &DeleteConfig{},
40 expectedErrorMsg: "config validation failed",
41 },
42 }
43
44 c, err := NewSonobuoyClient(nil, nil)
45 if err != nil {
46 t.Fatal(err)
47 }
48
49 for _, tc := range testcases {
50 t.Run(tc.desc, func(t *testing.T) {
51 err = c.Delete(tc.config)
52 expectedError := len(tc.expectedErrorMsg) > 0
53 if !expectedError && err != nil {
54 t.Errorf("Expected no error, got: %v", err)
55 }
56
57 if expectedError {
58 if err == nil {
59 t.Errorf("Expected provided config to be invalid but got no error")
60 } else if !strings.Contains(err.Error(), tc.expectedErrorMsg) {
61 t.Errorf("Expected error to contain '%v', got '%v'", tc.expectedErrorMsg, err.Error())
62 }
63 }
64 })
65 }
66}
67
68func TestIsE2ENamespace(t *testing.T) {
69 testcases := []struct {

Callers

nothing calls this directly

Calls 4

DeleteMethod · 0.95
NewSonobuoyClientFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected