package exception_test import ( "fmt" "testing" "git.apihub24.de/admin/exception" "github.com/stretchr/testify/suite" ) type CustomExceptionTestSuite struct { suite.Suite } func (suite *CustomExceptionTestSuite) TestShouldCreateCustomException() { ex := exception.NewCustom("fail") suite.NotNil(ex) suite.Equal(ex.Error(), "[fail]:") } func (suite *CustomExceptionTestSuite) TestShouldAddInnerError() { ex := exception.NewCustom("fail", fmt.Errorf("innerError")) suite.NotNil(ex) suite.Equal(ex.Error(), "[fail]:\ninnerError") } func (suite *CustomExceptionTestSuite) TestShouldAddInnerErrors() { ex := exception.NewCustom("fail", fmt.Errorf("innerError1"), fmt.Errorf("innerError2")) suite.NotNil(ex) suite.Equal(ex.Error(), "[fail]:\ninnerError1\ninnerError2") } func (suite *CustomExceptionTestSuite) TestShouldAddInnerErrorsAfterCreation() { ex := exception.NewCustom("fail") ex.With(fmt.Errorf("innerError1"), fmt.Errorf("innerError2")) suite.NotNil(ex) suite.Equal(ex.Error(), "[fail]:\ninnerError1\ninnerError2") } func TestCustomExceptionTestSuite(t *testing.T) { suite.Run(t, new(CustomExceptionTestSuiteeee)) }