(ctx context.Context, fooRef cache.ObjectName, startInformers bool, expectError bool)
| 118 | } |
| 119 | |
| 120 | func (f *fixture) runController(ctx context.Context, fooRef cache.ObjectName, startInformers bool, expectError bool) { |
| 121 | c, i, k8sI := f.newController(ctx) |
| 122 | if startInformers { |
| 123 | i.Start(ctx.Done()) |
| 124 | k8sI.Start(ctx.Done()) |
| 125 | } |
| 126 | |
| 127 | err := c.syncHandler(ctx, fooRef) |
| 128 | if !expectError && err != nil { |
| 129 | f.t.Errorf("error syncing foo: %v", err) |
| 130 | } else if expectError && err == nil { |
| 131 | f.t.Error("expected error syncing foo, got nil") |
| 132 | } |
| 133 | |
| 134 | actions := filterInformerActions(f.client.Actions()) |
| 135 | for i, action := range actions { |
| 136 | if len(f.actions) < i+1 { |
| 137 | f.t.Errorf("%d unexpected actions: %+v", len(actions)-len(f.actions), actions[i:]) |
| 138 | break |
| 139 | } |
| 140 | |
| 141 | expectedAction := f.actions[i] |
| 142 | checkAction(expectedAction, action, f.t) |
| 143 | } |
| 144 | |
| 145 | if len(f.actions) > len(actions) { |
| 146 | f.t.Errorf("%d additional expected actions:%+v", len(f.actions)-len(actions), f.actions[len(actions):]) |
| 147 | } |
| 148 | |
| 149 | k8sActions := filterInformerActions(f.kubeclient.Actions()) |
| 150 | for i, action := range k8sActions { |
| 151 | if len(f.kubeactions) < i+1 { |
| 152 | f.t.Errorf("%d unexpected actions: %+v", len(k8sActions)-len(f.kubeactions), k8sActions[i:]) |
| 153 | break |
| 154 | } |
| 155 | |
| 156 | expectedAction := f.kubeactions[i] |
| 157 | checkAction(expectedAction, action, f.t) |
| 158 | } |
| 159 | |
| 160 | if len(f.kubeactions) > len(k8sActions) { |
| 161 | f.t.Errorf("%d additional expected actions:%+v", len(f.kubeactions)-len(k8sActions), f.kubeactions[len(k8sActions):]) |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // checkAction verifies that expected and actual actions are equal and both have |
| 166 | // same attached resources |
no test coverage detected