Skip to content

Commit

Permalink
feat(test): error.go
Browse files Browse the repository at this point in the history
  • Loading branch information
toopay committed Jul 14, 2024
1 parent ccaf1bd commit 4473ccd
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,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())
}

0 comments on commit 4473ccd

Please sign in to comment.