-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy patherrors_test.go
72 lines (68 loc) · 2.32 KB
/
errors_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
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
package amboy
import (
"testing"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
func TestDuplicateError(t *testing.T) {
t.Run("RegularErrorIsNotDuplicate", func(t *testing.T) {
err := errors.New("err")
assert.False(t, IsDuplicateJobError(err))
assert.False(t, IsDuplicateJobScopeError(err))
})
t.Run("NilErrorIsNotDuplicate", func(t *testing.T) {
assert.False(t, IsDuplicateJobError(nil))
assert.False(t, IsDuplicateJobScopeError(nil))
})
t.Run("NewDuplicateJobError", func(t *testing.T) {
err := NewDuplicateJobError("err")
assert.True(t, IsDuplicateJobError(err))
assert.False(t, IsDuplicateJobScopeError(err))
})
t.Run("NewDuplicateJobErrorf", func(t *testing.T) {
err := NewDuplicateJobErrorf("err %s", "err")
assert.True(t, IsDuplicateJobError(err))
assert.False(t, IsDuplicateJobScopeError(err))
})
t.Run("MakeDuplicateJobError", func(t *testing.T) {
err := MakeDuplicateJobError(errors.New("err"))
assert.True(t, IsDuplicateJobError(err))
assert.False(t, IsDuplicateJobScopeError(err))
})
t.Run("NewDuplicateJobScopeError", func(t *testing.T) {
err := NewDuplicateJobScopeError("err")
assert.True(t, IsDuplicateJobError(err))
assert.True(t, IsDuplicateJobScopeError(err))
})
t.Run("NewDuplicateScopeJobErrorf", func(t *testing.T) {
err := NewDuplicateJobScopeErrorf("err %s", "err")
assert.True(t, IsDuplicateJobError(err))
assert.True(t, IsDuplicateJobScopeError(err))
})
t.Run("MakeDuplicateScopeJobError", func(t *testing.T) {
err := MakeDuplicateJobScopeError(errors.New("err"))
assert.True(t, IsDuplicateJobError(err))
assert.True(t, IsDuplicateJobScopeError(err))
})
}
func TestJobNotFoundError(t *testing.T) {
t.Run("RegularErrorIsNotJobNotFound", func(t *testing.T) {
err := errors.New("err")
assert.False(t, IsJobNotFoundError(err))
})
t.Run("NilErrorIsNotDuplicate", func(t *testing.T) {
assert.False(t, IsJobNotFoundError(nil))
})
t.Run("NewJobNotFoundError", func(t *testing.T) {
err := NewJobNotFoundError("err")
assert.True(t, IsJobNotFoundError(err))
})
t.Run("NewJobNotFoundErrorf", func(t *testing.T) {
err := NewJobNotFoundErrorf("err %s", "err")
assert.True(t, IsJobNotFoundError(err))
})
t.Run("MakeJobNotFoundError", func(t *testing.T) {
err := MakeJobNotFoundError(errors.New("err"))
assert.True(t, IsJobNotFoundError(err))
})
}