diff --git a/integration/context_test.go b/integration/context_test.go index 73bf407a..a4fa6267 100644 --- a/integration/context_test.go +++ b/integration/context_test.go @@ -12,9 +12,9 @@ func TestContexts(t *testing.T) { TestDir: "testdata/contexts", Commands: []Command{ { - Command: "config get-contexts", - ExpectedCode: 0, - ExpectedOutput: "get-contexts.txt", + Command: "config get-contexts", + ExpectedCode: 0, + ExpectedOutputFile: "get-contexts.txt", }, }, }) diff --git a/integration/dashboard_test.go b/integration/dashboard_test.go index e0e78ef2..0941f779 100644 --- a/integration/dashboard_test.go +++ b/integration/dashboard_test.go @@ -14,9 +14,9 @@ func TestDashboard(t *testing.T) { RunOnContexts: allContexts, Commands: []Command{ { - Command: "get Dashboard.ReciqtgGk", - ExpectedCode: 0, - ExpectedOutput: "ReciqtgGk.json", + Command: "get Dashboard.ReciqtgGk", + ExpectedCode: 0, + ExpectedOutputFile: "ReciqtgGk.json", }, }, }) diff --git a/integration/utils_test.go b/integration/utils_test.go index 9e03d1f8..4016e5d7 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -18,6 +18,7 @@ type Command struct { ExpectedCode int ExpectedError error ExpectedOutput string + ExpectedOutputFile string ExpectedOutputContains string } type GrizzlyTest struct { @@ -46,10 +47,14 @@ func runTest(t *testing.T, test GrizzlyTest) { require.Error(t, err, command.ExpectedError) } require.Equal(t, command.ExpectedCode, exitCode, "Exited with %d (%d expected).\nOutput: %s\nstderr: %s", exitCode, command.ExpectedCode, stdout, stderr) - if command.ExpectedOutput != "" { - data, err := os.ReadFile(filepath.Join(test.TestDir, command.ExpectedOutput)) + // Check stdout + if command.ExpectedOutputFile != "" { + bytes, err := os.ReadFile(filepath.Join(test.TestDir, command.ExpectedOutputFile)) require.NoError(t, err) - require.Equal(t, string(data), stdout) + command.ExpectedOutput = string(bytes) + } + if command.ExpectedOutput != "" { + require.Equal(t, command.ExpectedOutput, stdout) } if command.ExpectedOutputContains != "" { require.Contains(t, stdout, command.ExpectedOutputContains)