github.com/prysmaticlabs/prysm@v1.4.4/shared/testutil/require/requires.go (about) 1 package require 2 3 import ( 4 "github.com/prysmaticlabs/prysm/shared/testutil/assertions" 5 "github.com/sirupsen/logrus/hooks/test" 6 ) 7 8 // Equal compares values using comparison operator. 9 func Equal(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) { 10 assertions.Equal(tb.Fatalf, expected, actual, msg...) 11 } 12 13 // NotEqual compares values using comparison operator. 14 func NotEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) { 15 assertions.NotEqual(tb.Fatalf, expected, actual, msg...) 16 } 17 18 // DeepEqual compares values using DeepEqual. 19 // NOTE: this function does not work for checking arrays/slices or maps of protobuf messages. 20 // For arrays/slices, please use DeepSSZEqual. 21 // For maps, please iterate through and compare the individual keys and values. 22 func DeepEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) { 23 assertions.DeepEqual(tb.Fatalf, expected, actual, msg...) 24 } 25 26 // DeepNotEqual compares values using DeepEqual. 27 // NOTE: this function does not work for checking arrays/slices or maps of protobuf messages. 28 // For arrays/slices, please use DeepNotSSZEqual. 29 // For maps, please iterate through and compare the individual keys and values. 30 func DeepNotEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) { 31 assertions.DeepNotEqual(tb.Fatalf, expected, actual, msg...) 32 } 33 34 // DeepSSZEqual compares values using DeepEqual. 35 func DeepSSZEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) { 36 assertions.DeepSSZEqual(tb.Fatalf, expected, actual, msg...) 37 } 38 39 // DeepNotSSZEqual compares values using DeepEqual. 40 func DeepNotSSZEqual(tb assertions.AssertionTestingTB, expected, actual interface{}, msg ...interface{}) { 41 assertions.DeepNotSSZEqual(tb.Fatalf, expected, actual, msg...) 42 } 43 44 // NoError asserts that error is nil. 45 func NoError(tb assertions.AssertionTestingTB, err error, msg ...interface{}) { 46 assertions.NoError(tb.Fatalf, err, msg...) 47 } 48 49 // ErrorContains asserts that actual error contains wanted message. 50 func ErrorContains(tb assertions.AssertionTestingTB, want string, err error, msg ...interface{}) { 51 assertions.ErrorContains(tb.Fatalf, want, err, msg...) 52 } 53 54 // NotNil asserts that passed value is not nil. 55 func NotNil(tb assertions.AssertionTestingTB, obj interface{}, msg ...interface{}) { 56 assertions.NotNil(tb.Fatalf, obj, msg...) 57 } 58 59 // LogsContain checks that the desired string is a subset of the current log output. 60 func LogsContain(tb assertions.AssertionTestingTB, hook *test.Hook, want string, msg ...interface{}) { 61 assertions.LogsContain(tb.Fatalf, hook, want, true, msg...) 62 } 63 64 // LogsDoNotContain is the inverse check of LogsContain. 65 func LogsDoNotContain(tb assertions.AssertionTestingTB, hook *test.Hook, want string, msg ...interface{}) { 66 assertions.LogsContain(tb.Fatalf, hook, want, false, msg...) 67 }