flabk/pkg/epk/epk.go

35 lines
732 B
Go
Raw Permalink Normal View History

package epk
import "github.com/stretchr/testify/require"
type ErrorTest func(*require.Assertions, error)
var (
NoError ErrorTest = func(a *require.Assertions, err error) {
a.NoError(err)
}
Error ErrorTest = func(a *require.Assertions, err error) {
a.Error(err)
}
)
func ErrorIs(target error, contains ...string) ErrorTest {
return func(a *require.Assertions, err error) {
a.Error(err)
a.ErrorIs(err, target)
for _, elem := range contains {
a.Contains(err.Error(), elem)
}
}
}
func NotErrorIs(target error, contains ...string) ErrorTest {
return func(a *require.Assertions, err error) {
a.Error(err)
a.NotErrorIs(err, target)
for _, elem := range contains {
a.Contains(err.Error(), elem)
}
}
}