(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func TestIsDeprecated(t *testing.T) { |
| 32 | |
| 33 | testCases := []struct { |
| 34 | Name string |
| 35 | Err error |
| 36 | expect bool |
| 37 | }{ |
| 38 | { |
| 39 | Name: "deprecated", |
| 40 | Err: NewDeprecated(resource("test"), types.NamespacedName{}), |
| 41 | expect: true, |
| 42 | }, |
| 43 | { |
| 44 | Name: "no deprecated", |
| 45 | Err: fmt.Errorf("test"), |
| 46 | expect: false, |
| 47 | }, |
| 48 | } |
| 49 | |
| 50 | err := NewDeprecated(resource("test"), types.NamespacedName{}) |
| 51 | if err.Details() == nil { |
| 52 | t.Errorf("expect error details %v is not nil", err.Details()) |
| 53 | } |
| 54 | |
| 55 | if len(err.Error()) == 0 { |
| 56 | t.Errorf("expect error is not empty, but %v", err.Error()) |
| 57 | } |
| 58 | |
| 59 | for _, testCase := range testCases { |
| 60 | if testCase.expect != IsDeprecated(testCase.Err) { |
| 61 | t.Errorf("testCase %s: expected %v ,got %v", testCase.Name, testCase.expect, IsDeprecated(testCase.Err)) |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func TestIsNotSupported(t *testing.T) { |
| 67 | testCases := []struct { |
nothing calls this directly
no test coverage detected