2021-10-04 15:14:52 +00:00
|
|
|
package cstest
|
|
|
|
|
|
|
|
import (
|
2022-02-15 11:50:33 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-09-30 14:01:42 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-10-04 15:14:52 +00:00
|
|
|
)
|
|
|
|
|
2022-02-15 11:50:33 +00:00
|
|
|
func AssertErrorContains(t *testing.T, err error, expectedErr string) {
|
2022-09-30 14:01:42 +00:00
|
|
|
t.Helper()
|
|
|
|
|
2022-05-18 08:08:37 +00:00
|
|
|
if expectedErr != "" {
|
|
|
|
assert.ErrorContains(t, err, expectedErr)
|
2022-02-15 11:50:33 +00:00
|
|
|
return
|
|
|
|
}
|
2022-05-18 08:08:37 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
2022-02-15 11:50:33 +00:00
|
|
|
}
|
2022-09-30 14:01:42 +00:00
|
|
|
|
|
|
|
func RequireErrorContains(t *testing.T, err error, expectedErr string) {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
if expectedErr != "" {
|
|
|
|
require.ErrorContains(t, err, expectedErr)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|