Core system #1
1 changed files with 23 additions and 0 deletions
23
internal/core/errors_test.go
Normal file
23
internal/core/errors_test.go
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewError(t *testing.T) {
|
||||||
|
err := NewHTTPError(http.StatusBadRequest, "MyError", errors.New("test"))
|
||||||
|
assert.Equal(t, http.StatusBadRequest, err.Code)
|
||||||
|
assert.Equal(t, "MyError", err.Error())
|
||||||
|
assert.Equal(t, errors.New("test"), err.Unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewInternalServerError(t *testing.T) {
|
||||||
|
err := NewInternalServerError(errors.New("test"))
|
||||||
|
assert.Equal(t, http.StatusInternalServerError, err.Code)
|
||||||
|
assert.Equal(t, "Internal server error", err.Error())
|
||||||
|
assert.Equal(t, errors.New("test"), err.Unwrap())
|
||||||
|
}
|
Loading…
Reference in a new issue