-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathtask_test.go
More file actions
30 lines (24 loc) · 564 Bytes
/
Copy pathtask_test.go
File metadata and controls
30 lines (24 loc) · 564 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package pond
import (
"errors"
"testing"
"github.com/alitto/pond/v2/internal/assert"
)
func TestInvokeTaskHandlesPanicByDefault(t *testing.T) {
sampleErr := errors.New("sample error")
err := func() (err error) {
_, err = invokeTask[struct{}](func() {
panic(sampleErr)
}, true)
return
}()
assert.True(t, errors.Is(err, ErrPanic))
assert.True(t, errors.Is(err, sampleErr))
}
func TestInvokeTaskWithoutPanicRecoveryPanics(t *testing.T) {
assert.PanicsWith(t, "boom", func() {
invokeTask[struct{}](func() {
panic("boom")
}, false)
})
}