-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_test.go
55 lines (43 loc) · 1.08 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func somethingError() error {
return errors.New("테스트")
}
func Test_APIErrorFromErrorCode(t *testing.T) {
assert := assert.New(t)
assert.Equal(
"알수없는 오류",
UnknownError.CreateError(nil).Error(),
"UnknownError's Message")
assert.Equal(
"알수없는 오류: 테스트",
UnknownError.CreateError(somethingError()).Error(),
"inner Error print test")
}
func Test_MakeErrorMessage(t *testing.T) {
assert := assert.New(t)
err := UnknownError.CreateError(somethingError())
message := MakeErrorMessage(err)
assert.Equal(
"알수없는 오류: 테스트",
message.Message,
"ErrorMessage message test",
)
err = NetworkError.CreateError(somethingError())
message = MakeErrorMessage(err)
assert.Equal(message.StatusCode, 404, "Check StatusCode")
}
func Test_WhereIsError(t *testing.T) {
assert := assert.New(t)
err := somethingError()
WhereInError(&err, "아무튼")
assert.Equal(
"아무튼 오류: 테스트",
err.Error(),
"WhereInError message append test",
)
}