forked from fschnko/repeat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_test.go
More file actions
44 lines (41 loc) · 893 Bytes
/
error_test.go
File metadata and controls
44 lines (41 loc) · 893 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package repeat
import (
"errors"
"testing"
)
func TestExecuteError(t *testing.T) {
cases := []struct {
reason Reason
count int
err error
wont string
}{
{
reason: "",
count: 0,
err: nil,
wont: "execution stopped after 0 attempt",
}, {
reason: "",
count: 10,
err: nil,
wont: "execution stopped after 10 attempt",
}, {
reason: ContextDoneSignal,
count: 10,
err: nil,
wont: "execution stopped after 10 attempt, reason: received completion signal from the context",
}, {
reason: "",
count: 10,
err: errors.New("callback error"),
wont: "execution stopped after 10 attempt, with error: callback error",
},
}
for _, c := range cases {
e := &ExecuteError{c.reason, c.count, c.err}
if got := e.Error(); got != c.wont {
t.Errorf("&ExecuteError.Error() got %q, want %q", got, c.wont)
}
}
}