-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwith_test.go
42 lines (40 loc) · 902 Bytes
/
with_test.go
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
package delaying
import (
"testing"
"time"
)
func TestWith(t *testing.T) {
type args struct {
queue string
path string
delay time.Duration
}
tests := []struct {
name string
args args
want params
expectsPanic bool
}{
{"full", args{"queue1", "path1", 3}, params{"queue1", "path1", 3}, false},
{"empty_queue", args{"", "path1", 3}, params{}, true},
{"empty_path", args{"queue1", "", 3}, params{}, true},
{"negative_delay", args{"queue1", "path1", -1}, params{}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.expectsPanic {
defer func() {
if r := recover(); r == nil {
t.Errorf("With() did not panic")
}
}()
}
p := With(tt.args.queue, tt.args.path, tt.args.delay)
if !tt.expectsPanic {
if p != tt.want {
t.Errorf("With() = %v, want %v", p, tt.want)
}
}
})
}
}