1232 lines · 43.5 KB · Go
RawDownload
/** CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen* THIS FILE MUST NOT BE EDITED BY HAND */ package assert import (	http "net/http"	url "net/url"	time "time") // Condition uses a Comparison to assert a complex condition.func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Condition(a.t, comp, msgAndArgs...)} // Conditionf uses a Comparison to assert a complex condition.func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Conditionf(a.t, comp, msg, args...)} // Contains asserts that the specified string, list(array, slice...) or map contains the// specified substring or element.////    a.Contains("Hello World", "World")//    a.Contains(["Hello", "World"], "World")//    a.Contains({"Hello": "World"}, "Hello")func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Contains(a.t, s, contains, msgAndArgs...)} // Containsf asserts that the specified string, list(array, slice...) or map contains the// specified substring or element.////    a.Containsf("Hello World", "World", "error message %s", "formatted")//    a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")//    a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Containsf(a.t, s, contains, msg, args...)} // DirExists checks whether a directory exists in the given path. It also fails// if the path is a file rather a directory or there is an error checking whether it exists.func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return DirExists(a.t, path, msgAndArgs...)} // DirExistsf checks whether a directory exists in the given path. It also fails// if the path is a file rather a directory or there is an error checking whether it exists.func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return DirExistsf(a.t, path, msg, args...)} // ElementsMatch asserts that the specified listA(array, slice...) is equal to specified// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,// the number of appearances of each of them in both lists should match.//// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return ElementsMatch(a.t, listA, listB, msgAndArgs...)} // ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,// the number of appearances of each of them in both lists should match.//// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return ElementsMatchf(a.t, listA, listB, msg, args...)} // Empty asserts that the specified object is empty.  I.e. nil, "", false, 0 or either// a slice or a channel with len == 0.////  a.Empty(obj)func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Empty(a.t, object, msgAndArgs...)} // Emptyf asserts that the specified object is empty.  I.e. nil, "", false, 0 or either// a slice or a channel with len == 0.////  a.Emptyf(obj, "error message %s", "formatted")func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Emptyf(a.t, object, msg, args...)} // Equal asserts that two objects are equal.////    a.Equal(123, 123)//// Pointer variable equality is determined based on the equality of the// referenced values (as opposed to the memory addresses). Function equality// cannot be determined and will always fail.func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Equal(a.t, expected, actual, msgAndArgs...)} // EqualError asserts that a function returned an error (i.e. not `nil`)// and that it is equal to the provided error.////   actualObj, err := SomeFunction()//   a.EqualError(err,  expectedErrorString)func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return EqualError(a.t, theError, errString, msgAndArgs...)} // EqualErrorf asserts that a function returned an error (i.e. not `nil`)// and that it is equal to the provided error.////   actualObj, err := SomeFunction()//   a.EqualErrorf(err,  expectedErrorString, "error message %s", "formatted")func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return EqualErrorf(a.t, theError, errString, msg, args...)} // EqualValues asserts that two objects are equal or convertable to the same types// and equal.////    a.EqualValues(uint32(123), int32(123))func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return EqualValues(a.t, expected, actual, msgAndArgs...)} // EqualValuesf asserts that two objects are equal or convertable to the same types// and equal.////    a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123))func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return EqualValuesf(a.t, expected, actual, msg, args...)} // Equalf asserts that two objects are equal.////    a.Equalf(123, 123, "error message %s", "formatted")//// Pointer variable equality is determined based on the equality of the// referenced values (as opposed to the memory addresses). Function equality// cannot be determined and will always fail.func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Equalf(a.t, expected, actual, msg, args...)} // Error asserts that a function returned an error (i.e. not `nil`).////   actualObj, err := SomeFunction()//   if a.Error(err) {// 	   assert.Equal(t, expectedError, err)//   }func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Error(a.t, err, msgAndArgs...)} // Errorf asserts that a function returned an error (i.e. not `nil`).////   actualObj, err := SomeFunction()//   if a.Errorf(err, "error message %s", "formatted") {// 	   assert.Equal(t, expectedErrorf, err)//   }func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Errorf(a.t, err, msg, args...)} // Eventually asserts that given condition will be met in waitFor time,// periodically checking target function each tick.////    a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)} // Eventuallyf asserts that given condition will be met in waitFor time,// periodically checking target function each tick.////    a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Eventuallyf(a.t, condition, waitFor, tick, msg, args...)} // Exactly asserts that two objects are equal in value and type.////    a.Exactly(int32(123), int64(123))func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Exactly(a.t, expected, actual, msgAndArgs...)} // Exactlyf asserts that two objects are equal in value and type.////    a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Exactlyf(a.t, expected, actual, msg, args...)} // Fail reports a failure throughfunc (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Fail(a.t, failureMessage, msgAndArgs...)} // FailNow fails testfunc (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return FailNow(a.t, failureMessage, msgAndArgs...)} // FailNowf fails testfunc (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return FailNowf(a.t, failureMessage, msg, args...)} // Failf reports a failure throughfunc (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Failf(a.t, failureMessage, msg, args...)} // False asserts that the specified value is false.////    a.False(myBool)func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return False(a.t, value, msgAndArgs...)} // Falsef asserts that the specified value is false.////    a.Falsef(myBool, "error message %s", "formatted")func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Falsef(a.t, value, msg, args...)} // FileExists checks whether a file exists in the given path. It also fails if// the path points to a directory or there is an error when trying to check the file.func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return FileExists(a.t, path, msgAndArgs...)} // FileExistsf checks whether a file exists in the given path. It also fails if// the path points to a directory or there is an error when trying to check the file.func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return FileExistsf(a.t, path, msg, args...)} // Greater asserts that the first element is greater than the second////    a.Greater(2, 1)//    a.Greater(float64(2), float64(1))//    a.Greater("b", "a")func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Greater(a.t, e1, e2, msgAndArgs...)} // GreaterOrEqual asserts that the first element is greater than or equal to the second////    a.GreaterOrEqual(2, 1)//    a.GreaterOrEqual(2, 2)//    a.GreaterOrEqual("b", "a")//    a.GreaterOrEqual("b", "b")func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return GreaterOrEqual(a.t, e1, e2, msgAndArgs...)} // GreaterOrEqualf asserts that the first element is greater than or equal to the second////    a.GreaterOrEqualf(2, 1, "error message %s", "formatted")//    a.GreaterOrEqualf(2, 2, "error message %s", "formatted")//    a.GreaterOrEqualf("b", "a", "error message %s", "formatted")//    a.GreaterOrEqualf("b", "b", "error message %s", "formatted")func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return GreaterOrEqualf(a.t, e1, e2, msg, args...)} // Greaterf asserts that the first element is greater than the second////    a.Greaterf(2, 1, "error message %s", "formatted")//    a.Greaterf(float64(2, "error message %s", "formatted"), float64(1))//    a.Greaterf("b", "a", "error message %s", "formatted")func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return Greaterf(a.t, e1, e2, msg, args...)} // HTTPBodyContains asserts that a specified handler returns a// body that contains a string.////  a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)} // HTTPBodyContainsf asserts that a specified handler returns a// body that contains a string.////  a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)} // HTTPBodyNotContains asserts that a specified handler returns a// body that does not contain a string.////  a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)} // HTTPBodyNotContainsf asserts that a specified handler returns a// body that does not contain a string.////  a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)} // HTTPError asserts that a specified handler returns an error status code.////  a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPError(a.t, handler, method, url, values, msgAndArgs...)} // HTTPErrorf asserts that a specified handler returns an error status code.////  a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPErrorf(a.t, handler, method, url, values, msg, args...)} // HTTPRedirect asserts that a specified handler returns a redirect status code.////  a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)} // HTTPRedirectf asserts that a specified handler returns a redirect status code.////  a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}//// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPRedirectf(a.t, handler, method, url, values, msg, args...)} // HTTPSuccess asserts that a specified handler returns a success status code.////  a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {		h.Helper()	}	return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)} // HTTPSuccessf asserts that a specified handler returns a success status code.////  a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")//// Returns whether the assertion was successful (true) or not (false).func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {	if h, ok := a.t.(tHelper); ok {

Lines 1–500 of 1232.