From 1a5969e3146f2ff72186e5b46bf5ef39f21c7ef2 Mon Sep 17 00:00:00 2001 From: Muhammad Azeez Date: Wed, 10 Jul 2024 20:27:56 +0300 Subject: [PATCH] feat: print last output when doWaitFor times out (#117) * feat: print last output when doWaitFor times out * fix test --- exp/teatest/teatest.go | 2 +- exp/teatest/teatest_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exp/teatest/teatest.go b/exp/teatest/teatest.go index 9b99a546..d7166b2a 100644 --- a/exp/teatest/teatest.go +++ b/exp/teatest/teatest.go @@ -99,7 +99,7 @@ func doWaitFor(r io.Reader, condition func(bts []byte) bool, options ...WaitForO } time.Sleep(wf.CheckInterval) } - return fmt.Errorf("WaitFor: condition not met after %s", wf.Duration) + return fmt.Errorf("WaitFor: condition not met after %s. Last output:\n%s", wf.Duration, b.String()) } // TestModel is a model that is being tested. diff --git a/exp/teatest/teatest_test.go b/exp/teatest/teatest_test.go index 109908b3..c83f484f 100644 --- a/exp/teatest/teatest_test.go +++ b/exp/teatest/teatest_test.go @@ -29,7 +29,7 @@ func TestWaitForTimeout(t *testing.T) { if err == nil { t.Fatal("expected an error, got nil") } - if err.Error() != "WaitFor: condition not met after 1ms" { + if err.Error() != "WaitFor: condition not met after 1ms. Last output:\nnope" { t.Fatalf("unexpected error: %s", err.Error()) } }