From addd0d5e7b83ce528a313daccc6796275f4997b2 Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Thu, 13 Nov 2025 15:23:18 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20test=20for=20WaitForError=20p?= =?UTF-8?q?anic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waiterr.go | 2 +- waiterr_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/waiterr.go b/waiterr.go index b846952..156da4a 100644 --- a/waiterr.go +++ b/waiterr.go @@ -50,7 +50,7 @@ func (we *WaitErr) Go(f func() error) { // with that error. If all functions return successfully, a nil is returned. It will panic if called before Go. func (we *WaitErr) WaitForError() error { if we.errCh == nil { - panic("WaitForError called before Go, errCh is nil") + panic("WaitForError called before Go") } // Check if an error has already been set we.mut.RLock() diff --git a/waiterr_test.go b/waiterr_test.go index 3c74feb..a2691be 100644 --- a/waiterr_test.go +++ b/waiterr_test.go @@ -92,3 +92,14 @@ func TestUnwrap(tt *testing.T) { be.Equal(t, weNoErr.Unwrap(), nil) }) } + +func TestWaitForErrorPanic(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Errorf("The code did not panic") + } + }() + + we := new(waiterr.WaitErr) + _ = we.WaitForError() +}