2020-07-13 15:19:52 +00:00
|
|
|
package require
|
|
|
|
|
|
|
|
import (
|
2020-07-15 20:10:54 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assertions"
|
2020-08-13 16:22:25 +00:00
|
|
|
"github.com/sirupsen/logrus/hooks/test"
|
2020-07-13 15:19:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Equal compares values using comparison operator.
|
2020-07-20 01:36:28 +00:00
|
|
|
func Equal(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) {
|
2020-07-19 04:45:04 +00:00
|
|
|
assertions.Equal(tb.Fatalf, expected, actual, msg...)
|
2020-07-13 15:19:52 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 16:53:41 +00:00
|
|
|
// NotEqual compares values using comparison operator.
|
|
|
|
func NotEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) {
|
|
|
|
assertions.NotEqual(tb.Fatalf, expected, actual, msg...)
|
|
|
|
}
|
|
|
|
|
2020-07-13 15:19:52 +00:00
|
|
|
// DeepEqual compares values using DeepEqual.
|
2020-07-20 01:36:28 +00:00
|
|
|
func DeepEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) {
|
2020-07-19 04:45:04 +00:00
|
|
|
assertions.DeepEqual(tb.Fatalf, expected, actual, msg...)
|
2020-07-13 15:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NoError asserts that error is nil.
|
2020-07-20 01:36:28 +00:00
|
|
|
func NoError(tb assertions.AssertionTestingTB, err error, msg ...interface{}) {
|
2020-07-15 20:10:54 +00:00
|
|
|
assertions.NoError(tb.Fatalf, err, msg...)
|
2020-07-13 15:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ErrorContains asserts that actual error contains wanted message.
|
2020-07-20 01:36:28 +00:00
|
|
|
func ErrorContains(tb assertions.AssertionTestingTB, want string, err error, msg ...interface{}) {
|
2020-07-15 20:10:54 +00:00
|
|
|
assertions.ErrorContains(tb.Fatalf, want, err, msg...)
|
2020-07-13 15:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NotNil asserts that passed value is not nil.
|
2020-07-20 01:36:28 +00:00
|
|
|
func NotNil(tb assertions.AssertionTestingTB, obj interface{}, msg ...interface{}) {
|
2020-07-15 20:10:54 +00:00
|
|
|
assertions.NotNil(tb.Fatalf, obj, msg...)
|
2020-07-13 15:19:52 +00:00
|
|
|
}
|
2020-08-13 16:22:25 +00:00
|
|
|
|
|
|
|
// LogsContain checks that the desired string is a subset of the current log output.
|
|
|
|
func LogsContain(tb assertions.AssertionTestingTB, hook *test.Hook, want string, msg ...interface{}) {
|
|
|
|
assertions.LogsContain(tb.Fatalf, hook, want, true, msg...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LogsDoNotContain is the inverse check of LogsContain.
|
|
|
|
func LogsDoNotContain(tb assertions.AssertionTestingTB, hook *test.Hook, want string, msg ...interface{}) {
|
|
|
|
assertions.LogsContain(tb.Fatalf, hook, want, false, msg...)
|
|
|
|
}
|