(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func 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 | |
| 68 | func TestIsE2ENamespace(t *testing.T) { |
| 69 | testcases := []struct { |
nothing calls this directly
no test coverage detected