From 4ebcf025c68e6fe4f7756d2bff3fd697df4a45c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes=20Fernandes?= Date: Thu, 28 Aug 2025 20:01:11 -0300 Subject: [PATCH] fix `TestConsole*` tests on Windows (#3205) Signed-off-by: Diogenes Fernandes --- internal/command/console_interactive_test.go | 8 ++++++-- internal/command/console_test.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/command/console_interactive_test.go b/internal/command/console_interactive_test.go index ab88ec5e75..e33cf7eb7f 100644 --- a/internal/command/console_interactive_test.go +++ b/internal/command/console_interactive_test.go @@ -10,9 +10,11 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" "github.com/mitchellh/cli" "github.com/opentofu/opentofu/internal/configs/configschema" "github.com/opentofu/opentofu/internal/providers" + "github.com/opentofu/opentofu/internal/terminal" "github.com/zclconf/go-cty/cty" ) @@ -33,6 +35,7 @@ func TestConsole_multiline_interactive(t *testing.T) { }, }, } + streams, _ := terminal.StreamsForTesting(t) ui := cli.NewMockUi() view, _ := testView(t) c := &ConsoleCommand{ @@ -40,6 +43,7 @@ func TestConsole_multiline_interactive(t *testing.T) { testingOverrides: metaOverridesForProvider(p), Ui: ui, View: view, + Streams: streams, }, } @@ -113,8 +117,8 @@ func TestConsole_multiline_interactive(t *testing.T) { } got := output.String() - if got != tc.expected { - t.Fatalf("unexpected output. For input: %s\ngot: %q\nexpected: %q", tc.input, got, tc.expected) + if diff := cmp.Diff(got, tc.expected); diff != "" { + t.Fatalf("unexpected output. For input: %s\n%s", tc.input, diff) } }) } diff --git a/internal/command/console_test.go b/internal/command/console_test.go index 2073c7e4d0..6c3da93936 100644 --- a/internal/command/console_test.go +++ b/internal/command/console_test.go @@ -32,11 +32,13 @@ func TestConsole_basic(t *testing.T) { p := testProvider() ui := cli.NewMockUi() view, _ := testView(t) + streams, _ := terminal.StreamsForTesting(t) c := &ConsoleCommand{ Meta: Meta{ testingOverrides: metaOverridesForProvider(p), Ui: ui, View: view, + Streams: streams, }, }