-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse_test.go
More file actions
63 lines (58 loc) · 1.14 KB
/
Copy pathresponse_test.go
File metadata and controls
63 lines (58 loc) · 1.14 KB
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
package viya
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestErrorResponseErrorMessage(t *testing.T) {
t.Parallel()
tests := []struct {
name string
err ErrorResponse
expected string
}{
{
name: "empty error",
err: ErrorResponse{},
expected: "unknown error",
},
{
name: "with message",
err: ErrorResponse{
Message: "something went wrong",
},
expected: "something went wrong",
},
{
name: "with error info",
err: ErrorResponse{
ErrorInfo: &struct {
Code string `json:"code"`
Message string `json:"message"`
}{
Code: "SAS_ERROR",
Message: "auth failed",
},
},
expected: "auth failed",
},
{
name: "message takes precedence over error info",
err: ErrorResponse{
Message: "top level message",
ErrorInfo: &struct {
Code string `json:"code"`
Message string `json:"message"`
}{
Message: "nested message",
},
},
expected: "top level message",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.expected, tt.err.Error())
})
}
}