Skip to content

Commit

Permalink
Ensure we prepare new commands for rerun
Browse files Browse the repository at this point in the history
As we are now checking equality of consecutive runs, ensure we have
prepared mocks for them in the test metrics.
We can't reuse the same Cmd twice in a row.
  • Loading branch information
didrocks committed Oct 12, 2018
1 parent c6417fb commit ce03e0a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/metrics/metrics_test.go
Expand Up @@ -157,6 +157,24 @@ func TestRunCollectTwice(t *testing.T) {
metrics.WithArchitectureCommand(cmdArchitecture),
metrics.WithMapForEnv(tc.env))
b1, err1 := m.Collect()

cmdGPU, cancel = newMockShortCmd(t, "lspci", "-n", tc.caseGPU)
defer cancel()
cmdCPU, cancel = newMockShortCmd(t, "lscpu", "-J", tc.caseCPU)
defer cancel()
cmdScreen, cancel = newMockShortCmd(t, "xrandr", tc.caseScreen)
defer cancel()
cmdPartition, cancel = newMockShortCmd(t, "df", tc.casePartition)
defer cancel()
cmdArchitecture, cancel = newMockShortCmd(t, "dpkg", "--print-architecture", tc.caseArchitecture)
defer cancel()
m = newTestMetrics(t, metrics.WithRootAt(tc.root),
metrics.WithGPUInfoCommand(cmdGPU),
metrics.WithCPUInfoCommand(cmdCPU),
metrics.WithScreenInfoCommand(cmdScreen),
metrics.WithSpaceInfoCommand(cmdPartition),
metrics.WithArchitectureCommand(cmdArchitecture),
metrics.WithMapForEnv(tc.env))
b2, err2 := m.Collect()

a.CheckWantedErr(err1, tc.wantErr)
Expand Down

0 comments on commit ce03e0a

Please sign in to comment.