-
Notifications
You must be signed in to change notification settings - Fork 2
/
error_test.go
46 lines (38 loc) · 1.19 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
package raiden_test
import (
"testing"
"github.com/sev-2/raiden"
"github.com/stretchr/testify/assert"
)
func TestErrorResponse(t *testing.T) {
// Create an instance of ErrorResponse
errResp := &raiden.ErrorResponse{
StatusCode: 400,
Code: "BadRequest",
Details: "Invalid input",
Hint: "Check the input parameters",
Message: "Bad Request",
}
// Test ErrorResponse fields
assert.Equal(t, 400, errResp.StatusCode)
assert.Equal(t, "BadRequest", errResp.Code)
assert.Equal(t, "Invalid input", errResp.Details)
assert.Equal(t, "Check the input parameters", errResp.Hint)
assert.Equal(t, "Bad Request", errResp.Message)
// Test the Error method
assert.Equal(t, "Bad Request", errResp.Error())
}
func TestErrorResponse_EmptyFields(t *testing.T) {
// Create an instance of ErrorResponse with minimal fields
errResp := &raiden.ErrorResponse{
Message: "Error occurred",
}
// Test ErrorResponse fields
assert.Equal(t, 0, errResp.StatusCode)
assert.Equal(t, "", errResp.Code)
assert.Nil(t, errResp.Details)
assert.Equal(t, "", errResp.Hint)
assert.Equal(t, "Error occurred", errResp.Message)
// Test the Error method
assert.Equal(t, "Error occurred", errResp.Error())
}