From 00e17ff51c90acbd90a9d806cdd0e976767b4908 Mon Sep 17 00:00:00 2001 From: Will Yardley Date: Wed, 2 Oct 2024 03:16:40 -0700 Subject: [PATCH] test: use regex for expected value in `TestUiHookPreApply_periodicTimer` (#2035) Signed-off-by: William Yardley --- internal/command/views/hook_ui_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/command/views/hook_ui_test.go b/internal/command/views/hook_ui_test.go index b38f58eca7..2d24c4ec33 100644 --- a/internal/command/views/hook_ui_test.go +++ b/internal/command/views/hook_ui_test.go @@ -126,15 +126,15 @@ func TestUiHookPreApply_periodicTimer(t *testing.T) { close(uiState.DoneCh) <-uiState.done - expectedOutput := `test_instance.foo: Modifying... [id=test] -test_instance.foo: Still modifying... [id=test, 1s elapsed] -test_instance.foo: Still modifying... [id=test, 2s elapsed] -test_instance.foo: Still modifying... [id=test, 3s elapsed] + expectedRegexp := `test_instance\.foo: Modifying... \[id=test\] +test_instance\.foo: Still modifying... \[id=test, \ds elapsed\] +test_instance\.foo: Still modifying... \[id=test, \ds elapsed\] +test_instance\.foo: Still modifying... \[id=test, \ds elapsed\] ` result := done(t) output := result.Stdout() - if output != expectedOutput { - t.Fatalf("Output didn't match.\nExpected: %q\nGiven: %q", expectedOutput, output) + if matched, _ := regexp.MatchString(expectedRegexp, output); !matched { + t.Fatalf("Output didn't match.\nExpected: %q\nGiven: %q", expectedRegexp, output) } expectedErrOutput := ""