forked from gitploy-io/gitploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_test.go
More file actions
31 lines (27 loc) · 804 Bytes
/
code_test.go
File metadata and controls
31 lines (27 loc) · 804 Bytes
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
package e
import (
"fmt"
"testing"
)
func Test_IsError(t *testing.T) {
t.Run("Return true when the type of error is Error.", func(t *testing.T) {
err := NewError(ErrorCodeInternalError, nil)
if ok := IsError(err); !ok {
t.Fatalf("IsError = %v, wanted %v", ok, true)
}
})
t.Run("Return false when the type of error is not Error.", func(t *testing.T) {
err := fmt.Errorf("fmt.Error")
if ok := IsError(err); ok {
t.Fatalf("IsError = %v, wanted %v", ok, false)
}
})
}
func Test_HasErrorCode(t *testing.T) {
t.Run("Return true when the type of error is Error and the code is internal_error.", func(t *testing.T) {
err := NewError(ErrorCodeInternalError, nil)
if ok := HasErrorCode(err, ErrorCodeInternalError); !ok {
t.Fatalf("IsError = %v, wanted %v", ok, true)
}
})
}