From ce03e0a6178b93c5c42229510315c87c7d7c9ae4 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Fri, 12 Oct 2018 09:31:56 +0200 Subject: [PATCH] Ensure we prepare new commands for rerun 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. --- internal/metrics/metrics_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/metrics/metrics_test.go b/internal/metrics/metrics_test.go index 4cf220a..a7b393f 100644 --- a/internal/metrics/metrics_test.go +++ b/internal/metrics/metrics_test.go @@ -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)