-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patherror_test.go
41 lines (33 loc) · 981 Bytes
/
error_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
package conflate
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestMakeError_NoArgs(t *testing.T) {
err := makeError("err msg")
assert.Equal(t, err.Error(), "err msg")
}
func TestMakeError_WithArgs(t *testing.T) {
err := makeError("err %v", "msg")
assert.Equal(t, err.Error(), "err msg")
}
func TestMakeContextError_NoArgs(t *testing.T) {
err := makeContextError("ctx", "err msg")
assert.Equal(t, err.Error(), "err msg (ctx)")
}
func TestMakeContextError_WithArgs(t *testing.T) {
err := makeContextError("ctx", "err %v", "msg")
assert.Equal(t, err.Error(), "err msg (ctx)")
}
func TestWrapError_Nil(t *testing.T) {
err := wrapError(nil, "an error")
assert.Nil(t, err)
}
func TestWrapError_NoArgs(t *testing.T) {
err := wrapError(makeError("err2"), "err1")
assert.Equal(t, err.Error(), "err1 : err2")
}
func TestWrapError_WithArgs(t *testing.T) {
err := wrapError(makeError("err2"), "err%v", 1)
assert.Equal(t, err.Error(), "err1 : err2")
}