2020-07-13 15:19:52 +00:00
|
|
|
package assert
|
|
|
|
|
|
|
|
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.Errorf, 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.Errorf, expected, actual, msg...)
|
|
|
|
}
|
|
|
|
|
2020-07-13 15:19:52 +00:00
|
|
|
// DeepEqual compares values using DeepEqual.
|
2021-05-17 18:32:04 +00:00
|
|
|
// NOTE: this function does not work for checking arrays/slices or maps of protobuf messages.
|
|
|
|
// For arrays/slices, please use DeepSSZEqual.
|
|
|
|
// For maps, please iterate through and compare the individual keys and values.
|
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.Errorf, expected, actual, msg...)
|
2020-07-13 15:19:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-24 10:14:13 +00:00
|
|
|
// DeepNotEqual compares values using DeepEqual.
|
2021-05-17 18:32:04 +00:00
|
|
|
// NOTE: this function does not work for checking arrays/slices or maps of protobuf messages.
|
|
|
|
// For arrays/slices, please use DeepNotSSZEqual.
|
|
|
|
// For maps, please iterate through and compare the individual keys and values.
|
2020-08-24 10:14:13 +00:00
|
|
|
func DeepNotEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) {
|
|
|
|
assertions.DeepNotEqual(tb.Errorf, expected, actual, msg...)
|
|
|
|
}
|
|
|
|
|
2021-02-09 20:57:22 +00:00
|
|
|
// DeepSSZEqual compares values using sszutil.DeepEqual.
|
|
|
|
func DeepSSZEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) {
|
|
|
|
assertions.DeepSSZEqual(tb.Errorf, expected, actual, msg...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepNotSSZEqual compares values using sszutil.DeepEqual.
|
|
|
|
func DeepNotSSZEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) {
|
|
|
|
assertions.DeepNotSSZEqual(tb.Errorf, 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.Errorf, 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.Errorf, 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.Errorf, 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.Errorf, 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.Errorf, hook, want, false, msg...)
|
|
|
|
}
|