-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathjob_test.go
More file actions
51 lines (43 loc) · 1.44 KB
/
Copy pathjob_test.go
File metadata and controls
51 lines (43 loc) · 1.44 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
package river
import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/riverqueue/river/internal/dbunique"
"github.com/riverqueue/river/rivertype"
)
func TestUniqueOpts_isEmpty(t *testing.T) {
t.Parallel()
require.True(t, (&UniqueOpts{}).isEmpty())
require.False(t, (&UniqueOpts{ByArgs: true}).isEmpty())
require.False(t, (&UniqueOpts{ByPeriod: 1 * time.Nanosecond}).isEmpty())
require.False(t, (&UniqueOpts{ByQueue: true}).isEmpty())
require.False(t, (&UniqueOpts{ByState: []rivertype.JobState{rivertype.JobStateAvailable}}).isEmpty())
require.False(t, (&UniqueOpts{ExcludeKind: true}).isEmpty())
states := []rivertype.JobState{
rivertype.JobStateAvailable,
rivertype.JobStatePending,
rivertype.JobStateRunning,
rivertype.JobStateScheduled,
}
for _, byArgs := range []bool{false, true} {
for _, byQueue := range []bool{false, true} {
for _, byPeriod := range []time.Duration{0, 10 * time.Second} {
for _, byState := range [][]rivertype.JobState{nil, states} {
for _, excludeKind := range []bool{false, true} {
opts := UniqueOpts{
ByArgs: byArgs,
ByPeriod: byPeriod,
ByQueue: byQueue,
ByState: byState,
ExcludeKind: excludeKind,
}
internalOpts := (*dbunique.UniqueOpts)(&opts)
require.Equal(t, internalOpts.IsEmpty(), opts.isEmpty(),
"isEmpty and internal IsEmpty should agree for opts %+v", opts)
}
}
}
}
}
}