✅ Add test for WaitForError panic
This commit is contained in:
parent
09b97e0b66
commit
addd0d5e7b
2 changed files with 12 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue