vendor/github.com/stretchr/testify/assert/assertion_format.go
changeset 260 445e01aede7e
parent 256 6d9efbef00a9
equal deleted inserted replaced
259:db4911b0c721 260:445e01aede7e
   121 		h.Helper()
   121 		h.Helper()
   122 	}
   122 	}
   123 	return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
   123 	return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
   124 }
   124 }
   125 
   125 
       
   126 // ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
       
   127 // and that the error contains the specified substring.
       
   128 //
       
   129 //   actualObj, err := SomeFunction()
       
   130 //   assert.ErrorContainsf(t, err,  expectedErrorSubString, "error message %s", "formatted")
       
   131 func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool {
       
   132 	if h, ok := t.(tHelper); ok {
       
   133 		h.Helper()
       
   134 	}
       
   135 	return ErrorContains(t, theError, contains, append([]interface{}{msg}, args...)...)
       
   136 }
       
   137 
   126 // ErrorIsf asserts that at least one of the errors in err's chain matches target.
   138 // ErrorIsf asserts that at least one of the errors in err's chain matches target.
   127 // This is a wrapper for errors.Is.
   139 // This is a wrapper for errors.Is.
   128 func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
   140 func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
   129 	if h, ok := t.(tHelper); ok {
   141 	if h, ok := t.(tHelper); ok {
   130 		h.Helper()
   142 		h.Helper()
   722 		h.Helper()
   734 		h.Helper()
   723 	}
   735 	}
   724 	return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
   736 	return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
   725 }
   737 }
   726 
   738 
       
   739 // WithinRangef asserts that a time is within a time range (inclusive).
       
   740 //
       
   741 //   assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
       
   742 func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
       
   743 	if h, ok := t.(tHelper); ok {
       
   744 		h.Helper()
       
   745 	}
       
   746 	return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...)
       
   747 }
       
   748 
   727 // YAMLEqf asserts that two YAML strings are equivalent.
   749 // YAMLEqf asserts that two YAML strings are equivalent.
   728 func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
   750 func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
   729 	if h, ok := t.(tHelper); ok {
   751 	if h, ok := t.(tHelper); ok {
   730 		h.Helper()
   752 		h.Helper()
   731 	}
   753 	}