doExecuteTest runs Execute with the mitigate operation and reverse operation.
(t *testing.T, wantEnabled bool, wantCPUs int, wantErr subcommands.ExitStatus)
| 127 | |
| 128 | // doExecuteTest runs Execute with the mitigate operation and reverse operation. |
| 129 | func (m *Mitigate) doExecuteTest(t *testing.T, wantEnabled bool, wantCPUs int, wantErr subcommands.ExitStatus) { |
| 130 | subError := m.execute() |
| 131 | if subError != wantErr { |
| 132 | t.Fatalf("Mitigate error mismatch: want: %v got: %v", wantErr, subError) |
| 133 | } |
| 134 | |
| 135 | // case where test should end in error or we don't care |
| 136 | // about how many cpus are returned. |
| 137 | if wantErr != subcommands.ExitSuccess { |
| 138 | log.Infof("return") |
| 139 | return |
| 140 | } |
| 141 | |
| 142 | gotEnabled, _ := m.control.isEnabled() |
| 143 | if wantEnabled != gotEnabled { |
| 144 | t.Fatalf("Incorrect enabled state: want: %t got: %t", wantEnabled, gotEnabled) |
| 145 | } |
| 146 | |
| 147 | gotCPUs, _ := m.control.getCPUs() |
| 148 | if len(gotCPUs) != wantCPUs { |
| 149 | t.Fatalf("Incorrect number of CPUs: want: %d got: %d", wantCPUs, len(gotCPUs)) |
| 150 | } |
| 151 | } |