mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
fix assertion message formatting
Fail and HTTPBodyNotContains expected that Fail formats messages.
This commit is contained in:
parent
d77da356e5
commit
a55764f5c1
@ -849,9 +849,8 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool {
|
||||
// Returns whether the assertion was successful (true) or not (false).
|
||||
func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
|
||||
|
||||
message := messageFromMsgAndArgs(msgAndArgs...)
|
||||
if err == nil {
|
||||
return Fail(t, "An error is expected but got nil. %s", message)
|
||||
return Fail(t, "An error is expected but got nil.", msgAndArgs...)
|
||||
}
|
||||
|
||||
return true
|
||||
@ -861,9 +860,7 @@ func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
|
||||
// and that it is equal to the provided error.
|
||||
//
|
||||
// actualObj, err := SomeFunction()
|
||||
// if assert.Error(t, err, "An error was expected") {
|
||||
// assert.Equal(t, err, expectedError)
|
||||
// }
|
||||
// assert.EqualError(t, err, expectedErrorString, "An error was expected")
|
||||
//
|
||||
// Returns whether the assertion was successful (true) or not (false).
|
||||
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool {
|
||||
|
@ -99,7 +99,7 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url strin
|
||||
|
||||
contains := strings.Contains(body, fmt.Sprint(str))
|
||||
if contains {
|
||||
Fail(t, "Expected response body for %s to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)
|
||||
Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
|
||||
}
|
||||
|
||||
return !contains
|
||||
|
Loading…
x
Reference in New Issue
Block a user