Files
config/test/require/error.go
andrey 6d42e1a5f0
All checks were successful
Go Action / goaction (pull_request) Successful in 30s
Go Action / goaction (push) Successful in 48s
update values
2025-12-26 20:59:11 +03:00

45 lines
702 B
Go

package require
import (
"errors"
"testing"
)
func NoError(t *testing.T, err error, msgAndArgs ...any) {
t.Helper()
if err != nil {
t.Errorf("no error got:%v", err)
t.Error(msgAndArgs...)
t.FailNow()
}
}
func NoErrorf(t *testing.T, err error, msg string, args ...any) {
t.Helper()
if err != nil {
t.Errorf(msg, args...)
t.FailNow()
}
}
func ErrorIs(t *testing.T, err, ex error, msgAndArgs ...any) {
t.Helper()
if !errors.Is(err, ex) {
t.Errorf("expect:%#v got:%#v", ex, err)
t.Error(msgAndArgs...)
t.FailNow()
}
}
func ErrorIsf(t *testing.T, err, ex error, msg string, args ...any) {
t.Helper()
if !errors.Is(ex, err) {
t.Errorf(msg, args...)
t.FailNow()
}
}