vendor/github.com/stretchr/testify/assert/assertion_forward.go
changeset 260 445e01aede7e
parent 256 6d9efbef00a9
equal deleted inserted replaced
259:db4911b0c721 260:445e01aede7e
   220 		h.Helper()
   220 		h.Helper()
   221 	}
   221 	}
   222 	return ErrorAsf(a.t, err, target, msg, args...)
   222 	return ErrorAsf(a.t, err, target, msg, args...)
   223 }
   223 }
   224 
   224 
       
   225 // ErrorContains asserts that a function returned an error (i.e. not `nil`)
       
   226 // and that the error contains the specified substring.
       
   227 //
       
   228 //   actualObj, err := SomeFunction()
       
   229 //   a.ErrorContains(err,  expectedErrorSubString)
       
   230 func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool {
       
   231 	if h, ok := a.t.(tHelper); ok {
       
   232 		h.Helper()
       
   233 	}
       
   234 	return ErrorContains(a.t, theError, contains, msgAndArgs...)
       
   235 }
       
   236 
       
   237 // ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
       
   238 // and that the error contains the specified substring.
       
   239 //
       
   240 //   actualObj, err := SomeFunction()
       
   241 //   a.ErrorContainsf(err,  expectedErrorSubString, "error message %s", "formatted")
       
   242 func (a *Assertions) ErrorContainsf(theError error, contains string, msg string, args ...interface{}) bool {
       
   243 	if h, ok := a.t.(tHelper); ok {
       
   244 		h.Helper()
       
   245 	}
       
   246 	return ErrorContainsf(a.t, theError, contains, msg, args...)
       
   247 }
       
   248 
   225 // ErrorIs asserts that at least one of the errors in err's chain matches target.
   249 // ErrorIs asserts that at least one of the errors in err's chain matches target.
   226 // This is a wrapper for errors.Is.
   250 // This is a wrapper for errors.Is.
   227 func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
   251 func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
   228 	if h, ok := a.t.(tHelper); ok {
   252 	if h, ok := a.t.(tHelper); ok {
   229 		h.Helper()
   253 		h.Helper()
  1435 		h.Helper()
  1459 		h.Helper()
  1436 	}
  1460 	}
  1437 	return WithinDurationf(a.t, expected, actual, delta, msg, args...)
  1461 	return WithinDurationf(a.t, expected, actual, delta, msg, args...)
  1438 }
  1462 }
  1439 
  1463 
       
  1464 // WithinRange asserts that a time is within a time range (inclusive).
       
  1465 //
       
  1466 //   a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
       
  1467 func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool {
       
  1468 	if h, ok := a.t.(tHelper); ok {
       
  1469 		h.Helper()
       
  1470 	}
       
  1471 	return WithinRange(a.t, actual, start, end, msgAndArgs...)
       
  1472 }
       
  1473 
       
  1474 // WithinRangef asserts that a time is within a time range (inclusive).
       
  1475 //
       
  1476 //   a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
       
  1477 func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
       
  1478 	if h, ok := a.t.(tHelper); ok {
       
  1479 		h.Helper()
       
  1480 	}
       
  1481 	return WithinRangef(a.t, actual, start, end, msg, args...)
       
  1482 }
       
  1483 
  1440 // YAMLEq asserts that two YAML strings are equivalent.
  1484 // YAMLEq asserts that two YAML strings are equivalent.
  1441 func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
  1485 func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
  1442 	if h, ok := a.t.(tHelper); ok {
  1486 	if h, ok := a.t.(tHelper); ok {
  1443 		h.Helper()
  1487 		h.Helper()
  1444 	}
  1488 	}