This repository has been archived on 2022-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
DevOpsOpenHack/apis/trips/tripsgo/errorMessage_test.go

29 lines
655 B
Go
Raw Normal View History

2022-11-03 20:41:13 +00:00
package tripsgo
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSerializeErrorReturnsJsonIncludesErrorMessageUnit(t *testing.T) {
//arrange
expected := "{\"Message\":\"This is a fake error\"}"
err := errors.New("This is a fake error")
//act
actual := SerializeError(err, "")
//assert
assert.Equal(t, expected, actual)
}
func TestSerializeErrorReturnsJsonIncludesCustomMessageUnit(t *testing.T) {
//arrange
expected := "{\"Message\":\"more data: This is a fake error\"}"
err := errors.New("This is a fake error")
//act
actual := SerializeError(err, "more data")
//assert
assert.Equal(t, expected, actual)
}