mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
ErrorContains dont allow empty string (#11314)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -99,6 +99,9 @@ func ErrorIs(loggerFn assertionLoggerFn, err, target error, msg ...interface{})
|
||||
|
||||
// ErrorContains asserts that actual error contains wanted message.
|
||||
func ErrorContains(loggerFn assertionLoggerFn, want string, err error, msg ...interface{}) {
|
||||
if want == "" {
|
||||
loggerFn("Want string can't be empty")
|
||||
}
|
||||
if err == nil || !strings.Contains(err.Error(), want) {
|
||||
errMsg := parseMsg("Expected error not returned", msg...)
|
||||
_, file, line, _ := runtime.Caller(2)
|
||||
|
||||
@@ -564,6 +564,16 @@ func TestAssert_ErrorContains(t *testing.T) {
|
||||
},
|
||||
expectedErr: "",
|
||||
},
|
||||
{
|
||||
name: "expected error with params",
|
||||
args: args{
|
||||
tb: &assertions.TBMock{},
|
||||
want: "",
|
||||
err: errors.New("failed"),
|
||||
msgs: []interface{}{"Something wrong (for slot %d)", 12},
|
||||
},
|
||||
expectedErr: "Want string can't be empty",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
verify := func() {
|
||||
|
||||
Reference in New Issue
Block a user