checkAction verifies that expected and actual actions are equal and both have same attached resources
(expected, actual core.Action, t *testing.T)
| 165 | // checkAction verifies that expected and actual actions are equal and both have |
| 166 | // same attached resources |
| 167 | func checkAction(expected, actual core.Action, t *testing.T) { |
| 168 | if !(expected.Matches(actual.GetVerb(), actual.GetResource().Resource) && actual.GetSubresource() == expected.GetSubresource()) { |
| 169 | t.Errorf("Expected\n\t%#v\ngot\n\t%#v", expected, actual) |
| 170 | return |
| 171 | } |
| 172 | |
| 173 | if reflect.TypeOf(actual) != reflect.TypeOf(expected) { |
| 174 | t.Errorf("Action has wrong type. Expected: %t. Got: %t", expected, actual) |
| 175 | return |
| 176 | } |
| 177 | |
| 178 | switch a := actual.(type) { |
| 179 | case core.CreateActionImpl: |
| 180 | e, _ := expected.(core.CreateActionImpl) |
| 181 | expObject := e.GetObject() |
| 182 | object := a.GetObject() |
| 183 | |
| 184 | if !reflect.DeepEqual(expObject, object) { |
| 185 | t.Errorf("Action %s %s has wrong object\nDiff:\n %s", |
| 186 | a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object)) |
| 187 | } |
| 188 | case core.UpdateActionImpl: |
| 189 | e, _ := expected.(core.UpdateActionImpl) |
| 190 | expObject := e.GetObject() |
| 191 | object := a.GetObject() |
| 192 | |
| 193 | if !reflect.DeepEqual(expObject, object) { |
| 194 | t.Errorf("Action %s %s has wrong object\nDiff:\n %s", |
| 195 | a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object)) |
| 196 | } |
| 197 | case core.PatchActionImpl: |
| 198 | e, _ := expected.(core.PatchActionImpl) |
| 199 | expPatch := e.GetPatch() |
| 200 | patch := a.GetPatch() |
| 201 | |
| 202 | if !reflect.DeepEqual(expPatch, patch) { |
| 203 | t.Errorf("Action %s %s has wrong patch\nDiff:\n %s", |
| 204 | a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expPatch, patch)) |
| 205 | } |
| 206 | default: |
| 207 | t.Errorf("Uncaptured Action %s %s, you should explicitly add a case to capture it", |
| 208 | actual.GetVerb(), actual.GetResource().Resource) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | // filterInformerActions filters list and watch actions for testing resources. |
| 213 | // Since list and watch don't change resource state we can filter it to lower |
no outgoing calls
no test coverage detected
searching dependent graphs…