This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
error_test.go
79 lines (63 loc) · 1.8 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package schemaregistry
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_IsSubjectNotFound(t *testing.T) {
err := ResourceError{
ErrorCode: subjectNotFoundCode,
Method: "GET",
URI: "some-uri",
Message: "some-error",
}
assert.True(t, IsSubjectNotFound(err))
assert.False(t, IsSchemaNotFound(err))
}
func Test_IsSubjectNotFound_with_no_error(t *testing.T) {
assert.False(t, IsSubjectNotFound(nil))
}
func Test_IsSubjectNotFound_with_system_error(t *testing.T) {
assert.False(t, IsSubjectNotFound(fmt.Errorf("some-error")))
}
func Test_IsVersionNotFound(t *testing.T) {
err := ResourceError{
ErrorCode: versionNotFoundCode,
Method: "GET",
URI: "some-uri",
Message: "some-error",
}
assert.True(t, IsVersionNotFound(err))
assert.False(t, IsSubjectNotFound(err))
}
func Test_IsVersionNotFound_with_no_error(t *testing.T) {
assert.False(t, IsVersionNotFound(nil))
}
func Test_IsVersionNotFound_with_system_error(t *testing.T) {
assert.False(t, IsVersionNotFound(fmt.Errorf("some-error")))
}
func Test_IsSchemaNotFound(t *testing.T) {
err := ResourceError{
ErrorCode: schemaNotFoundCode,
Method: "GET",
URI: "some-uri",
Message: "some-error",
}
assert.True(t, IsSchemaNotFound(err))
assert.False(t, IsSubjectNotFound(err))
}
func Test_IsSchemaNotFound_with_no_error(t *testing.T) {
assert.False(t, IsSchemaNotFound(nil))
}
func Test_IsSchemaNotFound_with_system_error(t *testing.T) {
assert.False(t, IsSchemaNotFound(fmt.Errorf("some-error")))
}
func Test_ResourceError_Error_format(t *testing.T) {
err := ResourceError{
ErrorCode: schemaNotFoundCode,
Method: "GET",
URI: "some-uri",
Message: "some-error",
}
assert.Equal(t, "client: (GET: some-uri) failed with error code 40403: some-error", err.Error())
}