-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_test.go
More file actions
126 lines (119 loc) · 2.27 KB
/
utils_test.go
File metadata and controls
126 lines (119 loc) · 2.27 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package goqueue
import (
"github.com/streadway/amqp"
"github.com/stretchr/testify/assert"
"testing"
"time"
)
func Test_getRetry(t *testing.T) {
subtests := []struct {
title string
headers amqp.Table
retry int
}{
{
title: "Can get correct int retry",
headers: amqp.Table{
RetryHeader: 3,
},
retry: 3,
},
{
title: "Can get correct int32 retry",
headers: amqp.Table{
RetryHeader: int32(4),
},
retry: 4,
},
{
title: "Can get correct int64 retry",
headers: amqp.Table{
RetryHeader: int64(5),
},
retry: 5,
},
{
title: "Can get default zero for unsupported type",
headers: amqp.Table{
RetryHeader: "20",
},
retry: 0,
},
{
title: "Can get zero retry",
headers: amqp.Table{},
retry: 0,
},
}
for _, subtest := range subtests {
t.Run(subtest.title, func(t *testing.T) {
assert.Equal(t, subtest.retry, getRetry(subtest.headers))
})
}
}
func Test_getExchangeName(t *testing.T) {
subtests := []struct {
title string
queue string
retry int
exchange string
}{
{
title: "Can get name",
queue: "test",
retry: -1,
exchange: "test",
},
{
title: "Can get retry name",
queue: "test",
retry: 20,
exchange: "test__retry",
},
}
for _, subtest := range subtests {
t.Run(subtest.title, func(t *testing.T) {
assert.Equal(t, subtest.exchange, getExchangeName(subtest.queue, subtest.retry))
})
}
}
func Test_getQueueName(t *testing.T) {
subtests := []struct {
title string
queue string
retry int
intervals []time.Duration
queueName string
}{
{
title: "Can get name",
queue: "test",
retry: -1,
intervals: []time.Duration{},
queueName: "test",
},
{
title: "Can get retry name",
queue: "test",
retry: 2,
intervals: []time.Duration{
1 * time.Second,
5 * time.Second,
10 * time.Second,
},
queueName: "test__retry__10s",
},
{
title: "Can get retry overflow name",
queue: "test",
retry: 10,
intervals: []time.Duration{},
queueName: "",
},
}
for _, subtest := range subtests {
t.Run(subtest.title, func(t *testing.T) {
assert.Equal(t, subtest.queueName, getQueueName(subtest.queue, subtest.retry, subtest.intervals))
})
}
}