Catch additional errors
This commit is contained in:
parent
a5b9d2ff34
commit
c4d3ab3bd5
20 changed files with 1709 additions and 138 deletions
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -30,7 +30,7 @@ memo = "3aa439f7fd3be3f2266640afdb7c86c6225490d5e1e14404bef5be1eaab6f640"
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/mastertinner/adapters"
|
name = "github.com/mastertinner/adapters"
|
||||||
packages = [".","logging"]
|
packages = [".","logging"]
|
||||||
revision = "842cd783e24e05aaf08852d5f6279dbcfd51ae4b"
|
revision = "c9f5d039ae85e86c09980d986e1452be5cffa00e"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -60,4 +60,4 @@ memo = "3aa439f7fd3be3f2266640afdb7c86c6225490d5e1e14404bef5be1eaab6f640"
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/stretchr/testify"
|
name = "github.com/stretchr/testify"
|
||||||
packages = ["assert"]
|
packages = ["assert"]
|
||||||
revision = "b8c9b4ef3dade3a13f662c95942dcda39e962cd4"
|
revision = "cc189738c010cb847790782fd5f87d4e0002da9d"
|
||||||
|
|
|
@ -27,14 +27,14 @@ var (
|
||||||
// handleHTTPError handles HTTP errors.
|
// handleHTTPError handles HTTP errors.
|
||||||
func handleHTTPError(w http.ResponseWriter, err error) {
|
func handleHTTPError(w http.ResponseWriter, err error) {
|
||||||
var code int
|
var code int
|
||||||
|
|
||||||
switch err := errors.Cause(err).(type) {
|
switch err := errors.Cause(err).(type) {
|
||||||
case *json.SyntaxError:
|
case *json.SyntaxError:
|
||||||
code = http.StatusUnprocessableEntity
|
code = http.StatusUnprocessableEntity
|
||||||
default:
|
default:
|
||||||
if err == io.EOF {
|
if err == io.EOF || err == io.ErrUnexpectedEOF {
|
||||||
code = http.StatusUnprocessableEntity
|
code = http.StatusUnprocessableEntity
|
||||||
} else if err == ErrBucketDoesNotExist ||
|
} else if err == ErrBucketDoesNotExist || err == ErrKeyDoesNotExist {
|
||||||
err == ErrKeyDoesNotExist {
|
|
||||||
code = http.StatusNotFound
|
code = http.StatusNotFound
|
||||||
} else {
|
} else {
|
||||||
code = http.StatusInternalServerError
|
code = http.StatusInternalServerError
|
||||||
|
|
26
vendor/github.com/mastertinner/adapters/LICENSE
generated
vendored
26
vendor/github.com/mastertinner/adapters/LICENSE
generated
vendored
|
@ -1,19 +1,13 @@
|
||||||
Copyright (c) 2017 Tobias Fuhrimann
|
Copyright 2017 Tobias Fuhrimann
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
you may not use this file except in compliance with the License.
|
||||||
in the Software without restriction, including without limitation the rights
|
You may obtain a copy of the License at
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
Unless required by applicable law or agreed to in writing, software
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
See the License for the specific language governing permissions and
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
limitations under the License.
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
13
vendor/github.com/stretchr/testify/.travis.gogenerate.sh
generated
vendored
Executable file
13
vendor/github.com/stretchr/testify/.travis.gogenerate.sh
generated
vendored
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ "$TRAVIS_GO_VERSION" =~ ^1\.[45](\..*)?$ ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
go get github.com/ernesto-jimenez/gogen/imports
|
||||||
|
go generate ./...
|
||||||
|
if [ -n "$(git diff)" ]; then
|
||||||
|
echo "Go generate had not been run"
|
||||||
|
git diff
|
||||||
|
exit 1
|
||||||
|
fi
|
10
vendor/github.com/stretchr/testify/.travis.govet.sh
generated
vendored
Executable file
10
vendor/github.com/stretchr/testify/.travis.govet.sh
generated
vendored
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd "$(dirname $0)"
|
||||||
|
DIRS=". assert require mock _codegen"
|
||||||
|
set -e
|
||||||
|
for subdir in $DIRS; do
|
||||||
|
pushd $subdir
|
||||||
|
go vet
|
||||||
|
popd
|
||||||
|
done
|
3
vendor/github.com/stretchr/testify/.travis.yml
generated
vendored
3
vendor/github.com/stretchr/testify/.travis.yml
generated
vendored
|
@ -7,8 +7,11 @@ go:
|
||||||
- 1.5
|
- 1.5
|
||||||
- 1.6
|
- 1.6
|
||||||
- 1.7
|
- 1.7
|
||||||
|
- 1.8
|
||||||
- tip
|
- tip
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- ./.travis.gogenerate.sh
|
||||||
- ./.travis.gofmt.sh
|
- ./.travis.gofmt.sh
|
||||||
|
- ./.travis.govet.sh
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
|
|
23
vendor/github.com/stretchr/testify/_codegen/main.go
generated
vendored
23
vendor/github.com/stretchr/testify/_codegen/main.go
generated
vendored
|
@ -20,6 +20,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pkg = flag.String("assert-path", "github.com/stretchr/testify/assert", "Path to the assert package")
|
pkg = flag.String("assert-path", "github.com/stretchr/testify/assert", "Path to the assert package")
|
||||||
|
includeF = flag.Bool("include-format-funcs", false, "include format functions such as Errorf and Equalf")
|
||||||
outputPkg = flag.String("output-package", "", "package for the resulting code")
|
outputPkg = flag.String("output-package", "", "package for the resulting code")
|
||||||
tmplFile = flag.String("template", "", "What file to load the function template from")
|
tmplFile = flag.String("template", "", "What file to load the function template from")
|
||||||
out = flag.String("out", "", "What file to write the source code to")
|
out = flag.String("out", "", "What file to write the source code to")
|
||||||
|
@ -157,6 +159,11 @@ func analyzeCode(scope *types.Scope, docs *doc.Package) (imports.Importer, []tes
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip functions ending with f
|
||||||
|
if strings.HasSuffix(fdocs.Name, "f") && !*includeF {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
funcs = append(funcs, testFunc{*outputPkg, fdocs, fn})
|
funcs = append(funcs, testFunc{*outputPkg, fdocs, fn})
|
||||||
importer.AddImportsFrom(sig.Params())
|
importer.AddImportsFrom(sig.Params())
|
||||||
}
|
}
|
||||||
|
@ -264,10 +271,26 @@ func (f *testFunc) ForwardedParams() string {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *testFunc) ParamsFormat() string {
|
||||||
|
return strings.Replace(f.Params(), "msgAndArgs", "msg string, args", 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *testFunc) ForwardedParamsFormat() string {
|
||||||
|
return strings.Replace(f.ForwardedParams(), "msgAndArgs", "append([]interface{}{msg}, args...)", 1)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *testFunc) Comment() string {
|
func (f *testFunc) Comment() string {
|
||||||
return "// " + strings.Replace(strings.TrimSpace(f.DocInfo.Doc), "\n", "\n// ", -1)
|
return "// " + strings.Replace(strings.TrimSpace(f.DocInfo.Doc), "\n", "\n// ", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *testFunc) CommentFormat() string {
|
||||||
|
search := fmt.Sprintf("%s", f.DocInfo.Name)
|
||||||
|
replace := fmt.Sprintf("%sf", f.DocInfo.Name)
|
||||||
|
comment := strings.Replace(f.Comment(), search, replace, -1)
|
||||||
|
exp := regexp.MustCompile(replace + `\(((\(\)|[^)])+)\)`)
|
||||||
|
return exp.ReplaceAllString(comment, replace+`($1, "error message %s", "formatted")`)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *testFunc) CommentWithoutT(receiver string) string {
|
func (f *testFunc) CommentWithoutT(receiver string) string {
|
||||||
search := fmt.Sprintf("assert.%s(t, ", f.DocInfo.Name)
|
search := fmt.Sprintf("assert.%s(t, ", f.DocInfo.Name)
|
||||||
replace := fmt.Sprintf("%s.%s(", receiver, f.DocInfo.Name)
|
replace := fmt.Sprintf("%s.%s(", receiver, f.DocInfo.Name)
|
||||||
|
|
368
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
Normal file
368
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
Normal file
|
@ -0,0 +1,368 @@
|
||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Conditionf uses a Comparison to assert a complex condition.
|
||||||
|
func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
|
||||||
|
return Condition(t, comp, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Containsf asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// assert.Emptyf(t, obj, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Empty(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// assert.Equalf(t, 123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
|
||||||
|
return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errorf asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.Errorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedErrorf, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
|
||||||
|
return Error(t, err, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// assert.Falsef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
|
||||||
|
return False(t, value, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyContains(t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyNotContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyNotContains(t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPErrorf asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPErrorf(t, 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 HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPError(t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPRedirectf(t, 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 HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPRedirect(t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccessf asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPSuccess(t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
|
||||||
|
return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
|
||||||
|
return Len(t, object, length, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// assert.Nilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Nil(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.NoErrorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
|
||||||
|
return NoError(t, err, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// assert.NotNilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotNil(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return NotPanics(t, f, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotZero(t, i, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return Panics(t, f, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// assert.Truef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
|
||||||
|
return True(t, value, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
|
||||||
|
return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Zero(t, i, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
4
vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl
generated
vendored
Normal file
4
vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{.CommentFormat}}
|
||||||
|
func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool {
|
||||||
|
return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}})
|
||||||
|
}
|
402
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
402
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
|
@ -16,18 +16,35 @@ func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool
|
||||||
return Condition(a.t, comp, msgAndArgs...)
|
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 {
|
||||||
|
return Conditionf(a.t, comp, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
|
// a.Contains("Hello World", "World")
|
||||||
// a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
|
// a.Contains(["Hello", "World"], "World")
|
||||||
// a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
|
// a.Contains({"Hello": "World"}, "Hello")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return Contains(a.t, s, contains, msgAndArgs...)
|
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")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Containsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
@ -38,9 +55,19 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return Empty(a.t, object, msgAndArgs...)
|
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")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Emptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Equal asserts that two objects are equal.
|
// Equal asserts that two objects are equal.
|
||||||
//
|
//
|
||||||
// a.Equal(123, 123, "123 and 123 should be equal")
|
// a.Equal(123, 123)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -54,27 +81,60 @@ func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs
|
||||||
// and that it is equal to the provided error.
|
// and that it is equal to the provided error.
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// a.EqualError(err, expectedErrorString, "An error was expected")
|
// a.EqualError(err, expectedErrorString)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
|
||||||
return EqualError(a.t, theError, errString, msgAndArgs...)
|
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")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool {
|
||||||
|
return EqualErrorf(a.t, theError, errString, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
|
// a.EqualValues(uint32(123), int32(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return EqualValues(a.t, expected, actual, msgAndArgs...)
|
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))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return EqualValuesf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// a.Equalf(123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Equalf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Error asserts that a function returned an error (i.e. not `nil`).
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// if a.Error(err, "An error was expected") {
|
// if a.Error(err) {
|
||||||
// assert.Equal(t, expectedError, err)
|
// assert.Equal(t, expectedError, err)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -83,15 +143,36 @@ func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
|
||||||
return Error(a.t, err, msgAndArgs...)
|
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)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {
|
||||||
|
return Errorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Exactly asserts that two objects are equal is value and type.
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
//
|
//
|
||||||
// a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
|
// a.Exactly(int32(123), int64(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return Exactly(a.t, expected, actual, msgAndArgs...)
|
return Exactly(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Exactlyf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Fail reports a failure through
|
// Fail reports a failure through
|
||||||
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
|
||||||
return Fail(a.t, failureMessage, msgAndArgs...)
|
return Fail(a.t, failureMessage, msgAndArgs...)
|
||||||
|
@ -102,15 +183,34 @@ func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) b
|
||||||
return FailNow(a.t, failureMessage, msgAndArgs...)
|
return FailNow(a.t, failureMessage, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return FailNowf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return Failf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// False asserts that the specified value is false.
|
// False asserts that the specified value is false.
|
||||||
//
|
//
|
||||||
// a.False(myBool, "myBool should be false")
|
// a.False(myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
|
||||||
return False(a.t, value, msgAndArgs...)
|
return False(a.t, value, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// a.Falsef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {
|
||||||
|
return Falsef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPBodyContains asserts that a specified handler returns a
|
// HTTPBodyContains asserts that a specified handler returns a
|
||||||
// body that contains a string.
|
// body that contains a string.
|
||||||
//
|
//
|
||||||
|
@ -121,6 +221,16 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, u
|
||||||
return HTTPBodyContains(a.t, handler, method, url, values, str)
|
return HTTPBodyContains(a.t, handler, method, url, values, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyContainsf(myHandler, "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{}) bool {
|
||||||
|
return HTTPBodyContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPBodyNotContains asserts that a specified handler returns a
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
||||||
// body that does not contain a string.
|
// body that does not contain a string.
|
||||||
//
|
//
|
||||||
|
@ -131,6 +241,16 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string
|
||||||
return HTTPBodyNotContains(a.t, handler, method, url, values, str)
|
return HTTPBodyNotContains(a.t, handler, method, url, values, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyNotContainsf(myHandler, "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{}) bool {
|
||||||
|
return HTTPBodyNotContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPError asserts that a specified handler returns an error status code.
|
// HTTPError asserts that a specified handler returns an error status code.
|
||||||
//
|
//
|
||||||
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
@ -140,6 +260,15 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri
|
||||||
return HTTPError(a.t, handler, method, url, values)
|
return HTTPError(a.t, handler, method, url, values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) bool {
|
||||||
|
return HTTPErrorf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
||||||
//
|
//
|
||||||
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
@ -149,6 +278,15 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s
|
||||||
return HTTPRedirect(a.t, handler, method, url, values)
|
return HTTPRedirect(a.t, handler, method, url, values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) bool {
|
||||||
|
return HTTPRedirectf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPSuccess asserts that a specified handler returns a success status code.
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
||||||
//
|
//
|
||||||
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
|
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
|
||||||
|
@ -158,13 +296,29 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url st
|
||||||
return HTTPSuccess(a.t, handler, method, url, values)
|
return HTTPSuccess(a.t, handler, method, url, values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) bool {
|
||||||
|
return HTTPSuccessf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
// Implements asserts that an object is implemented by the specified interface.
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
//
|
//
|
||||||
// a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
|
// a.Implements((*MyInterface)(nil), new(MyObject))
|
||||||
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return Implements(a.t, interfaceObject, object, msgAndArgs...)
|
return Implements(a.t, interfaceObject, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Implementsf(a.t, interfaceObject, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// InDelta asserts that the two numerals are within delta of each other.
|
// InDelta asserts that the two numerals are within delta of each other.
|
||||||
//
|
//
|
||||||
// a.InDelta(math.Pi, (22 / 7.0), 0.01)
|
// a.InDelta(math.Pi, (22 / 7.0), 0.01)
|
||||||
|
@ -179,6 +333,20 @@ func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delt
|
||||||
return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
|
return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDeltaf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
@ -191,11 +359,28 @@ func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, ep
|
||||||
return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
|
return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// IsType asserts that the specified objects are of the same type.
|
// IsType asserts that the specified objects are of the same type.
|
||||||
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return IsType(a.t, expectedType, object, msgAndArgs...)
|
return IsType(a.t, expectedType, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return IsTypef(a.t, expectedType, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// JSONEq asserts that two JSON strings are equivalent.
|
// JSONEq asserts that two JSON strings are equivalent.
|
||||||
//
|
//
|
||||||
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
||||||
|
@ -205,25 +390,53 @@ func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interf
|
||||||
return JSONEq(a.t, expected, actual, msgAndArgs...)
|
return JSONEq(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool {
|
||||||
|
return JSONEqf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Len asserts that the specified object has specific length.
|
// Len asserts that the specified object has specific length.
|
||||||
// Len also fails if the object has a type that len() not accept.
|
// Len also fails if the object has a type that len() not accept.
|
||||||
//
|
//
|
||||||
// a.Len(mySlice, 3, "The size of slice is not 3")
|
// a.Len(mySlice, 3)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
|
||||||
return Len(a.t, object, length, msgAndArgs...)
|
return Len(a.t, object, length, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// a.Lenf(mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool {
|
||||||
|
return Lenf(a.t, object, length, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Nil asserts that the specified object is nil.
|
// Nil asserts that the specified object is nil.
|
||||||
//
|
//
|
||||||
// a.Nil(err, "err should be nothing")
|
// a.Nil(err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return Nil(a.t, object, msgAndArgs...)
|
return Nil(a.t, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// a.Nilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Nilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NoError asserts that a function returned no error (i.e. `nil`).
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
|
@ -236,18 +449,42 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
|
||||||
return NoError(a.t, err, msgAndArgs...)
|
return NoError(a.t, err, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.NoErrorf(err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool {
|
||||||
|
return NoErrorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
// a.NotContains("Hello World", "Earth")
|
||||||
// a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
|
// a.NotContains(["Hello", "World"], "Earth")
|
||||||
// a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
|
// a.NotContains({"Hello": "World"}, "Earth")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return NotContains(a.t, s, contains, msgAndArgs...)
|
return NotContains(a.t, s, contains, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotContainsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
@ -260,9 +497,21 @@ func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) boo
|
||||||
return NotEmpty(a.t, object, msgAndArgs...)
|
return NotEmpty(a.t, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if a.NotEmptyf(obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEmptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotEqual asserts that the specified values are NOT equal.
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
//
|
//
|
||||||
// a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
|
// a.NotEqual(obj1, obj2)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -272,26 +521,54 @@ func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndAr
|
||||||
return NotEqual(a.t, expected, actual, msgAndArgs...)
|
return NotEqual(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEqualf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotNil asserts that the specified object is not nil.
|
// NotNil asserts that the specified object is not nil.
|
||||||
//
|
//
|
||||||
// a.NotNil(err, "err should be something")
|
// a.NotNil(err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return NotNil(a.t, object, msgAndArgs...)
|
return NotNil(a.t, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// a.NotNilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotNilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
//
|
//
|
||||||
// a.NotPanics(func(){
|
// a.NotPanics(func(){ RemainCalm() })
|
||||||
// RemainCalm()
|
|
||||||
// }, "Calling RemainCalm() should NOT panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
return NotPanics(a.t, f, msgAndArgs...)
|
return NotPanics(a.t, f, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return NotPanicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotRegexp asserts that a specified regexp does not match a string.
|
// NotRegexp asserts that a specified regexp does not match a string.
|
||||||
//
|
//
|
||||||
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
|
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
|
||||||
|
@ -302,6 +579,16 @@ func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...in
|
||||||
return NotRegexp(a.t, rx, str, msgAndArgs...)
|
return NotRegexp(a.t, rx, str, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotRegexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotSubset asserts that the specified list(array, slice...) contains not all
|
// NotSubset asserts that the specified list(array, slice...) contains not all
|
||||||
// elements given in the specified subset(array, slice...).
|
// elements given in the specified subset(array, slice...).
|
||||||
//
|
//
|
||||||
|
@ -312,22 +599,44 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs
|
||||||
return NotSubset(a.t, list, subset, msgAndArgs...)
|
return NotSubset(a.t, list, subset, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotSubsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
||||||
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return NotZero(a.t, i, msgAndArgs...)
|
return NotZero(a.t, i, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotZerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
//
|
//
|
||||||
// a.Panics(func(){
|
// a.Panics(func(){ GoCrazy() })
|
||||||
// GoCrazy()
|
|
||||||
// }, "Calling GoCrazy() should panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
return Panics(a.t, f, msgAndArgs...)
|
return Panics(a.t, f, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return Panicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Regexp asserts that a specified regexp matches a string.
|
// Regexp asserts that a specified regexp matches a string.
|
||||||
//
|
//
|
||||||
// a.Regexp(regexp.MustCompile("start"), "it's starting")
|
// a.Regexp(regexp.MustCompile("start"), "it's starting")
|
||||||
|
@ -338,6 +647,16 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter
|
||||||
return Regexp(a.t, rx, str, msgAndArgs...)
|
return Regexp(a.t, rx, str, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Regexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Subset asserts that the specified list(array, slice...) contains all
|
// Subset asserts that the specified list(array, slice...) contains all
|
||||||
// elements given in the specified subset(array, slice...).
|
// elements given in the specified subset(array, slice...).
|
||||||
//
|
//
|
||||||
|
@ -348,25 +667,58 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...
|
||||||
return Subset(a.t, list, subset, msgAndArgs...)
|
return Subset(a.t, list, subset, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Subsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// True asserts that the specified value is true.
|
// True asserts that the specified value is true.
|
||||||
//
|
//
|
||||||
// a.True(myBool, "myBool should be true")
|
// a.True(myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
|
||||||
return True(a.t, value, msgAndArgs...)
|
return True(a.t, value, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// a.Truef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool {
|
||||||
|
return Truef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// WithinDuration asserts that the two times are within duration delta of each other.
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
//
|
//
|
||||||
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
|
return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
|
||||||
|
return WithinDurationf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Zero asserts that i is the zero value for its type and returns the truth.
|
// Zero asserts that i is the zero value for its type and returns the truth.
|
||||||
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return Zero(a.t, i, msgAndArgs...)
|
return Zero(a.t, i, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Zerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
|
|
48
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
48
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
|
@ -18,6 +18,8 @@ import (
|
||||||
"github.com/pmezard/go-difflib/difflib"
|
"github.com/pmezard/go-difflib/difflib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_format.go.tmpl
|
||||||
|
|
||||||
// TestingT is an interface wrapper around *testing.T
|
// TestingT is an interface wrapper around *testing.T
|
||||||
type TestingT interface {
|
type TestingT interface {
|
||||||
Errorf(format string, args ...interface{})
|
Errorf(format string, args ...interface{})
|
||||||
|
@ -268,7 +270,7 @@ func labeledOutput(content ...labeledContent) string {
|
||||||
|
|
||||||
// Implements asserts that an object is implemented by the specified interface.
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
//
|
//
|
||||||
// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
|
// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
|
||||||
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
interfaceType := reflect.TypeOf(interfaceObject).Elem()
|
interfaceType := reflect.TypeOf(interfaceObject).Elem()
|
||||||
|
@ -293,7 +295,7 @@ func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs
|
||||||
|
|
||||||
// Equal asserts that two objects are equal.
|
// Equal asserts that two objects are equal.
|
||||||
//
|
//
|
||||||
// assert.Equal(t, 123, 123, "123 and 123 should be equal")
|
// assert.Equal(t, 123, 123)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -332,7 +334,7 @@ func formatUnequalValues(expected, actual interface{}) (e string, a string) {
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal")
|
// assert.EqualValues(t, uint32(123), int32(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -351,7 +353,7 @@ func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interfa
|
||||||
|
|
||||||
// Exactly asserts that two objects are equal is value and type.
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
//
|
//
|
||||||
// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal")
|
// assert.Exactly(t, int32(123), int64(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -369,7 +371,7 @@ func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
|
||||||
|
|
||||||
// NotNil asserts that the specified object is not nil.
|
// NotNil asserts that the specified object is not nil.
|
||||||
//
|
//
|
||||||
// assert.NotNil(t, err, "err should be something")
|
// assert.NotNil(t, err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -396,7 +398,7 @@ func isNil(object interface{}) bool {
|
||||||
|
|
||||||
// Nil asserts that the specified object is nil.
|
// Nil asserts that the specified object is nil.
|
||||||
//
|
//
|
||||||
// assert.Nil(t, err, "err should be nothing")
|
// assert.Nil(t, err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -519,7 +521,7 @@ func getLen(x interface{}) (ok bool, length int) {
|
||||||
// Len asserts that the specified object has specific length.
|
// Len asserts that the specified object has specific length.
|
||||||
// Len also fails if the object has a type that len() not accept.
|
// Len also fails if the object has a type that len() not accept.
|
||||||
//
|
//
|
||||||
// assert.Len(t, mySlice, 3, "The size of slice is not 3")
|
// assert.Len(t, mySlice, 3)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool {
|
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -536,7 +538,7 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
|
||||||
|
|
||||||
// True asserts that the specified value is true.
|
// True asserts that the specified value is true.
|
||||||
//
|
//
|
||||||
// assert.True(t, myBool, "myBool should be true")
|
// assert.True(t, myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -551,7 +553,7 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
// False asserts that the specified value is false.
|
// False asserts that the specified value is false.
|
||||||
//
|
//
|
||||||
// assert.False(t, myBool, "myBool should be false")
|
// assert.False(t, myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -566,7 +568,7 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
// NotEqual asserts that the specified values are NOT equal.
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
//
|
//
|
||||||
// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
|
// assert.NotEqual(t, obj1, obj2)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -623,9 +625,9 @@ func includeElement(list interface{}, element interface{}) (ok, found bool) {
|
||||||
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
|
// assert.Contains(t, "Hello World", "World")
|
||||||
// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
|
// assert.Contains(t, ["Hello", "World"], "World")
|
||||||
// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
|
// assert.Contains(t, {"Hello": "World"}, "Hello")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
|
func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -645,9 +647,9 @@ func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bo
|
||||||
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
// assert.NotContains(t, "Hello World", "Earth")
|
||||||
// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
|
// assert.NotContains(t, ["Hello", "World"], "Earth")
|
||||||
// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
|
// assert.NotContains(t, {"Hello": "World"}, "Earth")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
|
func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -787,9 +789,7 @@ func didPanic(f PanicTestFunc) (bool, interface{}) {
|
||||||
|
|
||||||
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
//
|
//
|
||||||
// assert.Panics(t, func(){
|
// assert.Panics(t, func(){ GoCrazy() })
|
||||||
// GoCrazy()
|
|
||||||
// }, "Calling GoCrazy() should panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -803,9 +803,7 @@ func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
//
|
//
|
||||||
// assert.NotPanics(t, func(){
|
// assert.NotPanics(t, func(){ RemainCalm() })
|
||||||
// RemainCalm()
|
|
||||||
// }, "Calling RemainCalm() should NOT panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -819,7 +817,7 @@ func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
|
||||||
// WithinDuration asserts that the two times are within duration delta of each other.
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
//
|
//
|
||||||
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -993,7 +991,7 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool {
|
||||||
// Error asserts that a function returned an error (i.e. not `nil`).
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// if assert.Error(t, err, "An error was expected") {
|
// if assert.Error(t, err) {
|
||||||
// assert.Equal(t, expectedError, err)
|
// assert.Equal(t, expectedError, err)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -1011,7 +1009,7 @@ func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
|
||||||
// and that it is equal to the provided error.
|
// and that it is equal to the provided error.
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// assert.EqualError(t, err, expectedErrorString, "An error was expected")
|
// assert.EqualError(t, err, expectedErrorString)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool {
|
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool {
|
||||||
|
|
7
vendor/github.com/stretchr/testify/assert/assertions_test.go
generated
vendored
7
vendor/github.com/stretchr/testify/assert/assertions_test.go
generated
vendored
|
@ -690,7 +690,7 @@ func TestNoError(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err == nil { // err is not nil here!
|
if err == nil { // err is not nil here!
|
||||||
t.Error("Error should be nil due to empty interface", err)
|
t.Errorf("Error should be nil due to empty interface: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
False(t, NoError(mockT, err), "NoError should fail with empty error interface")
|
False(t, NoError(mockT, err), "NoError should fail with empty error interface")
|
||||||
|
@ -714,6 +714,9 @@ func TestError(t *testing.T) {
|
||||||
|
|
||||||
True(t, Error(mockT, err), "Error with error should return True")
|
True(t, Error(mockT, err), "Error with error should return True")
|
||||||
|
|
||||||
|
// go vet check
|
||||||
|
True(t, Errorf(mockT, err, "example with %s", "formatted message"), "Errorf with error should rturn True")
|
||||||
|
|
||||||
// returning an empty error interface
|
// returning an empty error interface
|
||||||
err = func() error {
|
err = func() error {
|
||||||
var err *customError
|
var err *customError
|
||||||
|
@ -724,7 +727,7 @@ func TestError(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err == nil { // err is not nil here!
|
if err == nil { // err is not nil here!
|
||||||
t.Error("Error should be nil due to empty interface", err)
|
t.Errorf("Error should be nil due to empty interface: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
True(t, Error(mockT, err), "Error should pass with empty error interface")
|
True(t, Error(mockT, err), "Error should pass with empty error interface")
|
||||||
|
|
2
vendor/github.com/stretchr/testify/assert/forward_assertions.go
generated
vendored
2
vendor/github.com/stretchr/testify/assert/forward_assertions.go
generated
vendored
|
@ -13,4 +13,4 @@ func New(t TestingT) *Assertions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl
|
//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs
|
||||||
|
|
4
vendor/github.com/stretchr/testify/mock/mock_test.go
generated
vendored
4
vendor/github.com/stretchr/testify/mock/mock_test.go
generated
vendored
|
@ -754,7 +754,7 @@ func Test_AssertExpectationsForObjects_Helper(t *testing.T) {
|
||||||
mockedService2.Called(2)
|
mockedService2.Called(2)
|
||||||
mockedService3.Called(3)
|
mockedService3.Called(3)
|
||||||
|
|
||||||
assert.True(t, AssertExpectationsForObjects(t, mockedService1.Mock, mockedService2.Mock, mockedService3.Mock))
|
assert.True(t, AssertExpectationsForObjects(t, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock))
|
||||||
assert.True(t, AssertExpectationsForObjects(t, mockedService1, mockedService2, mockedService3))
|
assert.True(t, AssertExpectationsForObjects(t, mockedService1, mockedService2, mockedService3))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -773,7 +773,7 @@ func Test_AssertExpectationsForObjects_Helper_Failed(t *testing.T) {
|
||||||
mockedService3.Called(3)
|
mockedService3.Called(3)
|
||||||
|
|
||||||
tt := new(testing.T)
|
tt := new(testing.T)
|
||||||
assert.False(t, AssertExpectationsForObjects(tt, mockedService1.Mock, mockedService2.Mock, mockedService3.Mock))
|
assert.False(t, AssertExpectationsForObjects(tt, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock))
|
||||||
assert.False(t, AssertExpectationsForObjects(tt, mockedService1, mockedService2, mockedService3))
|
assert.False(t, AssertExpectationsForObjects(tt, mockedService1, mockedService2, mockedService3))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
2
vendor/github.com/stretchr/testify/require/forward_requirements.go
generated
vendored
2
vendor/github.com/stretchr/testify/require/forward_requirements.go
generated
vendored
|
@ -13,4 +13,4 @@ func New(t TestingT) *Assertions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl
|
//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl -include-format-funcs
|
||||||
|
|
482
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
482
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
|
@ -19,12 +19,19 @@ func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Conditionf uses a Comparison to assert a complex condition.
|
||||||
|
func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) {
|
||||||
|
if !assert.Conditionf(t, comp, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
|
// assert.Contains(t, "Hello World", "World")
|
||||||
// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
|
// assert.Contains(t, ["Hello", "World"], "World")
|
||||||
// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
|
// assert.Contains(t, {"Hello": "World"}, "Hello")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -33,6 +40,20 @@ func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Containsf asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Containsf(t, s, contains, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
@ -45,9 +66,21 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// assert.Emptyf(t, obj, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Emptyf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Equal asserts that two objects are equal.
|
// Equal asserts that two objects are equal.
|
||||||
//
|
//
|
||||||
// assert.Equal(t, 123, 123, "123 and 123 should be equal")
|
// assert.Equal(t, 123, 123)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -63,7 +96,7 @@ func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...i
|
||||||
// and that it is equal to the provided error.
|
// and that it is equal to the provided error.
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// assert.EqualError(t, err, expectedErrorString, "An error was expected")
|
// assert.EqualError(t, err, expectedErrorString)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
|
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
|
||||||
|
@ -72,10 +105,23 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
|
||||||
|
if !assert.EqualErrorf(t, theError, errString, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal")
|
// assert.EqualValues(t, uint32(123), int32(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -84,10 +130,36 @@ func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.EqualValuesf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// assert.Equalf(t, 123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Equalf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Error asserts that a function returned an error (i.e. not `nil`).
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// if assert.Error(t, err, "An error was expected") {
|
// if assert.Error(t, err) {
|
||||||
// assert.Equal(t, expectedError, err)
|
// assert.Equal(t, expectedError, err)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -98,9 +170,23 @@ func Error(t TestingT, err error, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Errorf asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.Errorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedErrorf, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Errorf(t TestingT, err error, msg string, args ...interface{}) {
|
||||||
|
if !assert.Errorf(t, err, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Exactly asserts that two objects are equal is value and type.
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
//
|
//
|
||||||
// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal")
|
// assert.Exactly(t, int32(123), int64(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -109,6 +195,17 @@ func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ..
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Exactlyf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fail reports a failure through
|
// Fail reports a failure through
|
||||||
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
||||||
if !assert.Fail(t, failureMessage, msgAndArgs...) {
|
if !assert.Fail(t, failureMessage, msgAndArgs...) {
|
||||||
|
@ -123,9 +220,23 @@ func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) {
|
||||||
|
if !assert.FailNowf(t, failureMessage, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
|
||||||
|
if !assert.Failf(t, failureMessage, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// False asserts that the specified value is false.
|
// False asserts that the specified value is false.
|
||||||
//
|
//
|
||||||
// assert.False(t, myBool, "myBool should be false")
|
// assert.False(t, myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func False(t TestingT, value bool, msgAndArgs ...interface{}) {
|
func False(t TestingT, value bool, msgAndArgs ...interface{}) {
|
||||||
|
@ -134,6 +245,17 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// assert.Falsef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
|
||||||
|
if !assert.Falsef(t, value, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPBodyContains asserts that a specified handler returns a
|
// HTTPBodyContains asserts that a specified handler returns a
|
||||||
// body that contains a string.
|
// body that contains a string.
|
||||||
//
|
//
|
||||||
|
@ -146,6 +268,18 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
if !assert.HTTPBodyContainsf(t, handler, method, url, values, str) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPBodyNotContains asserts that a specified handler returns a
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
||||||
// body that does not contain a string.
|
// body that does not contain a string.
|
||||||
//
|
//
|
||||||
|
@ -158,6 +292,18 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, ur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyNotContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
if !assert.HTTPBodyNotContainsf(t, handler, method, url, values, str) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPError asserts that a specified handler returns an error status code.
|
// HTTPError asserts that a specified handler returns an error status code.
|
||||||
//
|
//
|
||||||
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
@ -169,6 +315,17 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPErrorf asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPErrorf(t, 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 HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPErrorf(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
||||||
//
|
//
|
||||||
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
@ -180,6 +337,17 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPRedirectf(t, 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 HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPRedirectf(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPSuccess asserts that a specified handler returns a success status code.
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
||||||
//
|
//
|
||||||
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
|
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
|
||||||
|
@ -191,15 +359,35 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPSuccessf asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPSuccessf(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Implements asserts that an object is implemented by the specified interface.
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
//
|
//
|
||||||
// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
|
// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
|
||||||
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
|
if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Implementsf(t, interfaceObject, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// InDelta asserts that the two numerals are within delta of each other.
|
// InDelta asserts that the two numerals are within delta of each other.
|
||||||
//
|
//
|
||||||
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
|
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
|
||||||
|
@ -218,6 +406,24 @@ func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta fl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InDeltaf(t, expected, actual, delta, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
@ -234,6 +440,22 @@ func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// IsType asserts that the specified objects are of the same type.
|
// IsType asserts that the specified objects are of the same type.
|
||||||
func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
if !assert.IsType(t, expectedType, object, msgAndArgs...) {
|
if !assert.IsType(t, expectedType, object, msgAndArgs...) {
|
||||||
|
@ -241,6 +463,13 @@ func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.IsTypef(t, expectedType, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// JSONEq asserts that two JSON strings are equivalent.
|
// JSONEq asserts that two JSON strings are equivalent.
|
||||||
//
|
//
|
||||||
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
||||||
|
@ -252,10 +481,21 @@ func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
|
||||||
|
if !assert.JSONEqf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Len asserts that the specified object has specific length.
|
// Len asserts that the specified object has specific length.
|
||||||
// Len also fails if the object has a type that len() not accept.
|
// Len also fails if the object has a type that len() not accept.
|
||||||
//
|
//
|
||||||
// assert.Len(t, mySlice, 3, "The size of slice is not 3")
|
// assert.Len(t, mySlice, 3)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
|
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
|
||||||
|
@ -264,9 +504,21 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
|
||||||
|
if !assert.Lenf(t, object, length, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Nil asserts that the specified object is nil.
|
// Nil asserts that the specified object is nil.
|
||||||
//
|
//
|
||||||
// assert.Nil(t, err, "err should be nothing")
|
// assert.Nil(t, err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -275,6 +527,17 @@ func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// assert.Nilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Nilf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NoError asserts that a function returned no error (i.e. `nil`).
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
|
@ -289,12 +552,26 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.NoErrorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
|
||||||
|
if !assert.NoErrorf(t, err, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
// assert.NotContains(t, "Hello World", "Earth")
|
||||||
// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
|
// assert.NotContains(t, ["Hello", "World"], "Earth")
|
||||||
// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
|
// assert.NotContains(t, {"Hello": "World"}, "Earth")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -303,6 +580,20 @@ func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotContainsf(t, s, contains, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
@ -317,9 +608,23 @@ func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotEmptyf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotEqual asserts that the specified values are NOT equal.
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
//
|
//
|
||||||
// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
|
// assert.NotEqual(t, obj1, obj2)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -331,9 +636,23 @@ func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs .
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotEqualf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotNil asserts that the specified object is not nil.
|
// NotNil asserts that the specified object is not nil.
|
||||||
//
|
//
|
||||||
// assert.NotNil(t, err, "err should be something")
|
// assert.NotNil(t, err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -342,11 +661,20 @@ func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// assert.NotNilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotNilf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
//
|
//
|
||||||
// assert.NotPanics(t, func(){
|
// assert.NotPanics(t, func(){ RemainCalm() })
|
||||||
// RemainCalm()
|
|
||||||
// }, "Calling RemainCalm() should NOT panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
@ -355,6 +683,17 @@ func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotPanicsf(t, f, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotRegexp asserts that a specified regexp does not match a string.
|
// NotRegexp asserts that a specified regexp does not match a string.
|
||||||
//
|
//
|
||||||
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
|
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
|
||||||
|
@ -367,6 +706,18 @@ func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotRegexpf(t, rx, str, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotSubset asserts that the specified list(array, slice...) contains not all
|
// NotSubset asserts that the specified list(array, slice...) contains not all
|
||||||
// elements given in the specified subset(array, slice...).
|
// elements given in the specified subset(array, slice...).
|
||||||
//
|
//
|
||||||
|
@ -379,6 +730,18 @@ func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotSubsetf(t, list, subset, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
||||||
func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
||||||
if !assert.NotZero(t, i, msgAndArgs...) {
|
if !assert.NotZero(t, i, msgAndArgs...) {
|
||||||
|
@ -386,11 +749,16 @@ func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotZerof(t, i, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
//
|
//
|
||||||
// assert.Panics(t, func(){
|
// assert.Panics(t, func(){ GoCrazy() })
|
||||||
// GoCrazy()
|
|
||||||
// }, "Calling GoCrazy() should panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
@ -399,6 +767,17 @@ func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
if !assert.Panicsf(t, f, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Regexp asserts that a specified regexp matches a string.
|
// Regexp asserts that a specified regexp matches a string.
|
||||||
//
|
//
|
||||||
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
|
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
|
||||||
|
@ -411,6 +790,18 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Regexpf(t, rx, str, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Subset asserts that the specified list(array, slice...) contains all
|
// Subset asserts that the specified list(array, slice...) contains all
|
||||||
// elements given in the specified subset(array, slice...).
|
// elements given in the specified subset(array, slice...).
|
||||||
//
|
//
|
||||||
|
@ -423,9 +814,21 @@ func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...inte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Subsetf(t, list, subset, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// True asserts that the specified value is true.
|
// True asserts that the specified value is true.
|
||||||
//
|
//
|
||||||
// assert.True(t, myBool, "myBool should be true")
|
// assert.True(t, myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func True(t TestingT, value bool, msgAndArgs ...interface{}) {
|
func True(t TestingT, value bool, msgAndArgs ...interface{}) {
|
||||||
|
@ -434,9 +837,20 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// assert.Truef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Truef(t TestingT, value bool, msg string, args ...interface{}) {
|
||||||
|
if !assert.Truef(t, value, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithinDuration asserts that the two times are within duration delta of each other.
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
//
|
//
|
||||||
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
||||||
|
@ -445,9 +859,27 @@ func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
|
||||||
|
if !assert.WithinDurationf(t, expected, actual, delta, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Zero asserts that i is the zero value for its type and returns the truth.
|
// Zero asserts that i is the zero value for its type and returns the truth.
|
||||||
func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
||||||
if !assert.Zero(t, i, msgAndArgs...) {
|
if !assert.Zero(t, i, msgAndArgs...) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Zerof(t, i, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
402
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
402
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
|
@ -17,18 +17,35 @@ func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}
|
||||||
Condition(a.t, comp, msgAndArgs...)
|
Condition(a.t, comp, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Conditionf uses a Comparison to assert a complex condition.
|
||||||
|
func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) {
|
||||||
|
Conditionf(a.t, comp, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
|
// a.Contains("Hello World", "World")
|
||||||
// a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
|
// a.Contains(["Hello", "World"], "World")
|
||||||
// a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
|
// a.Contains({"Hello": "World"}, "Hello")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
Contains(a.t, s, contains, msgAndArgs...)
|
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")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
Containsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
@ -39,9 +56,19 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
|
||||||
Empty(a.t, object, msgAndArgs...)
|
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")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
Emptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Equal asserts that two objects are equal.
|
// Equal asserts that two objects are equal.
|
||||||
//
|
//
|
||||||
// a.Equal(123, 123, "123 and 123 should be equal")
|
// a.Equal(123, 123)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -55,27 +82,60 @@ func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs
|
||||||
// and that it is equal to the provided error.
|
// and that it is equal to the provided error.
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// a.EqualError(err, expectedErrorString, "An error was expected")
|
// a.EqualError(err, expectedErrorString)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
|
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
|
||||||
EqualError(a.t, theError, errString, msgAndArgs...)
|
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")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) {
|
||||||
|
EqualErrorf(a.t, theError, errString, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
|
// a.EqualValues(uint32(123), int32(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
EqualValues(a.t, expected, actual, msgAndArgs...)
|
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))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
EqualValuesf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// a.Equalf(123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
Equalf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Error asserts that a function returned an error (i.e. not `nil`).
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
// if a.Error(err, "An error was expected") {
|
// if a.Error(err) {
|
||||||
// assert.Equal(t, expectedError, err)
|
// assert.Equal(t, expectedError, err)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -84,15 +144,36 @@ func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
|
||||||
Error(a.t, err, msgAndArgs...)
|
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)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Errorf(err error, msg string, args ...interface{}) {
|
||||||
|
Errorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Exactly asserts that two objects are equal is value and type.
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
//
|
//
|
||||||
// a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
|
// a.Exactly(int32(123), int64(123))
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
Exactly(a.t, expected, actual, msgAndArgs...)
|
Exactly(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
Exactlyf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Fail reports a failure through
|
// Fail reports a failure through
|
||||||
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
|
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
|
||||||
Fail(a.t, failureMessage, msgAndArgs...)
|
Fail(a.t, failureMessage, msgAndArgs...)
|
||||||
|
@ -103,15 +184,34 @@ func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
|
||||||
FailNow(a.t, failureMessage, msgAndArgs...)
|
FailNow(a.t, failureMessage, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) {
|
||||||
|
FailNowf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) {
|
||||||
|
Failf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// False asserts that the specified value is false.
|
// False asserts that the specified value is false.
|
||||||
//
|
//
|
||||||
// a.False(myBool, "myBool should be false")
|
// a.False(myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
|
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
|
||||||
False(a.t, value, msgAndArgs...)
|
False(a.t, value, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// a.Falsef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) {
|
||||||
|
Falsef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPBodyContains asserts that a specified handler returns a
|
// HTTPBodyContains asserts that a specified handler returns a
|
||||||
// body that contains a string.
|
// body that contains a string.
|
||||||
//
|
//
|
||||||
|
@ -122,6 +222,16 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, u
|
||||||
HTTPBodyContains(a.t, handler, method, url, values, str)
|
HTTPBodyContains(a.t, handler, method, url, values, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyContainsf(myHandler, "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{}) {
|
||||||
|
HTTPBodyContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPBodyNotContains asserts that a specified handler returns a
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
||||||
// body that does not contain a string.
|
// body that does not contain a string.
|
||||||
//
|
//
|
||||||
|
@ -132,6 +242,16 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string
|
||||||
HTTPBodyNotContains(a.t, handler, method, url, values, str)
|
HTTPBodyNotContains(a.t, handler, method, url, values, str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyNotContainsf(myHandler, "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{}) {
|
||||||
|
HTTPBodyNotContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPError asserts that a specified handler returns an error status code.
|
// HTTPError asserts that a specified handler returns an error status code.
|
||||||
//
|
//
|
||||||
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
@ -141,6 +261,15 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri
|
||||||
HTTPError(a.t, handler, method, url, values)
|
HTTPError(a.t, handler, method, url, values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
HTTPErrorf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
||||||
//
|
//
|
||||||
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
@ -150,6 +279,15 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s
|
||||||
HTTPRedirect(a.t, handler, method, url, values)
|
HTTPRedirect(a.t, handler, method, url, values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
HTTPRedirectf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
// HTTPSuccess asserts that a specified handler returns a success status code.
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
||||||
//
|
//
|
||||||
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
|
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
|
||||||
|
@ -159,13 +297,29 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url st
|
||||||
HTTPSuccess(a.t, handler, method, url, values)
|
HTTPSuccess(a.t, handler, method, url, values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
HTTPSuccessf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
// Implements asserts that an object is implemented by the specified interface.
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
//
|
//
|
||||||
// a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
|
// a.Implements((*MyInterface)(nil), new(MyObject))
|
||||||
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
Implements(a.t, interfaceObject, object, msgAndArgs...)
|
Implements(a.t, interfaceObject, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
Implementsf(a.t, interfaceObject, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// InDelta asserts that the two numerals are within delta of each other.
|
// InDelta asserts that the two numerals are within delta of each other.
|
||||||
//
|
//
|
||||||
// a.InDelta(math.Pi, (22 / 7.0), 0.01)
|
// a.InDelta(math.Pi, (22 / 7.0), 0.01)
|
||||||
|
@ -180,6 +334,20 @@ func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delt
|
||||||
InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
|
InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
InDeltaf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
@ -192,11 +360,28 @@ func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, ep
|
||||||
InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
|
InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// IsType asserts that the specified objects are of the same type.
|
// IsType asserts that the specified objects are of the same type.
|
||||||
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
IsType(a.t, expectedType, object, msgAndArgs...)
|
IsType(a.t, expectedType, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
IsTypef(a.t, expectedType, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// JSONEq asserts that two JSON strings are equivalent.
|
// JSONEq asserts that two JSON strings are equivalent.
|
||||||
//
|
//
|
||||||
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
||||||
|
@ -206,25 +391,53 @@ func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interf
|
||||||
JSONEq(a.t, expected, actual, msgAndArgs...)
|
JSONEq(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) {
|
||||||
|
JSONEqf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Len asserts that the specified object has specific length.
|
// Len asserts that the specified object has specific length.
|
||||||
// Len also fails if the object has a type that len() not accept.
|
// Len also fails if the object has a type that len() not accept.
|
||||||
//
|
//
|
||||||
// a.Len(mySlice, 3, "The size of slice is not 3")
|
// a.Len(mySlice, 3)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
|
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
|
||||||
Len(a.t, object, length, msgAndArgs...)
|
Len(a.t, object, length, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// a.Lenf(mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) {
|
||||||
|
Lenf(a.t, object, length, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Nil asserts that the specified object is nil.
|
// Nil asserts that the specified object is nil.
|
||||||
//
|
//
|
||||||
// a.Nil(err, "err should be nothing")
|
// a.Nil(err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
|
||||||
Nil(a.t, object, msgAndArgs...)
|
Nil(a.t, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// a.Nilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
Nilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NoError asserts that a function returned no error (i.e. `nil`).
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
||||||
//
|
//
|
||||||
// actualObj, err := SomeFunction()
|
// actualObj, err := SomeFunction()
|
||||||
|
@ -237,18 +450,42 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
|
||||||
NoError(a.t, err, msgAndArgs...)
|
NoError(a.t, err, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.NoErrorf(err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) {
|
||||||
|
NoErrorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
// specified substring or element.
|
// specified substring or element.
|
||||||
//
|
//
|
||||||
// a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
|
// a.NotContains("Hello World", "Earth")
|
||||||
// a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
|
// a.NotContains(["Hello", "World"], "Earth")
|
||||||
// a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
|
// a.NotContains({"Hello": "World"}, "Earth")
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
NotContains(a.t, s, contains, msgAndArgs...)
|
NotContains(a.t, s, contains, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
NotContainsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
@ -261,9 +498,21 @@ func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
|
||||||
NotEmpty(a.t, object, msgAndArgs...)
|
NotEmpty(a.t, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if a.NotEmptyf(obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
NotEmptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotEqual asserts that the specified values are NOT equal.
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
//
|
//
|
||||||
// a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
|
// a.NotEqual(obj1, obj2)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
//
|
//
|
||||||
|
@ -273,26 +522,54 @@ func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndAr
|
||||||
NotEqual(a.t, expected, actual, msgAndArgs...)
|
NotEqual(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
NotEqualf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotNil asserts that the specified object is not nil.
|
// NotNil asserts that the specified object is not nil.
|
||||||
//
|
//
|
||||||
// a.NotNil(err, "err should be something")
|
// a.NotNil(err)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
|
||||||
NotNil(a.t, object, msgAndArgs...)
|
NotNil(a.t, object, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// a.NotNilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
NotNilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
//
|
//
|
||||||
// a.NotPanics(func(){
|
// a.NotPanics(func(){ RemainCalm() })
|
||||||
// RemainCalm()
|
|
||||||
// }, "Calling RemainCalm() should NOT panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
NotPanics(a.t, f, msgAndArgs...)
|
NotPanics(a.t, f, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
NotPanicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotRegexp asserts that a specified regexp does not match a string.
|
// NotRegexp asserts that a specified regexp does not match a string.
|
||||||
//
|
//
|
||||||
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
|
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
|
||||||
|
@ -303,6 +580,16 @@ func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...in
|
||||||
NotRegexp(a.t, rx, str, msgAndArgs...)
|
NotRegexp(a.t, rx, str, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
NotRegexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotSubset asserts that the specified list(array, slice...) contains not all
|
// NotSubset asserts that the specified list(array, slice...) contains not all
|
||||||
// elements given in the specified subset(array, slice...).
|
// elements given in the specified subset(array, slice...).
|
||||||
//
|
//
|
||||||
|
@ -313,22 +600,44 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs
|
||||||
NotSubset(a.t, list, subset, msgAndArgs...)
|
NotSubset(a.t, list, subset, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
NotSubsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
||||||
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
|
||||||
NotZero(a.t, i, msgAndArgs...)
|
NotZero(a.t, i, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) {
|
||||||
|
NotZerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
//
|
//
|
||||||
// a.Panics(func(){
|
// a.Panics(func(){ GoCrazy() })
|
||||||
// GoCrazy()
|
|
||||||
// }, "Calling GoCrazy() should panic")
|
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
Panics(a.t, f, msgAndArgs...)
|
Panics(a.t, f, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
Panicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Regexp asserts that a specified regexp matches a string.
|
// Regexp asserts that a specified regexp matches a string.
|
||||||
//
|
//
|
||||||
// a.Regexp(regexp.MustCompile("start"), "it's starting")
|
// a.Regexp(regexp.MustCompile("start"), "it's starting")
|
||||||
|
@ -339,6 +648,16 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter
|
||||||
Regexp(a.t, rx, str, msgAndArgs...)
|
Regexp(a.t, rx, str, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
Regexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Subset asserts that the specified list(array, slice...) contains all
|
// Subset asserts that the specified list(array, slice...) contains all
|
||||||
// elements given in the specified subset(array, slice...).
|
// elements given in the specified subset(array, slice...).
|
||||||
//
|
//
|
||||||
|
@ -349,25 +668,58 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...
|
||||||
Subset(a.t, list, subset, msgAndArgs...)
|
Subset(a.t, list, subset, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
Subsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// True asserts that the specified value is true.
|
// True asserts that the specified value is true.
|
||||||
//
|
//
|
||||||
// a.True(myBool, "myBool should be true")
|
// a.True(myBool)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
|
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
|
||||||
True(a.t, value, msgAndArgs...)
|
True(a.t, value, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// a.Truef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Truef(value bool, msg string, args ...interface{}) {
|
||||||
|
Truef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// WithinDuration asserts that the two times are within duration delta of each other.
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
//
|
//
|
||||||
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s")
|
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
|
||||||
//
|
//
|
||||||
// Returns whether the assertion was successful (true) or not (false).
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
||||||
WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
|
WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
|
||||||
|
WithinDurationf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Zero asserts that i is the zero value for its type and returns the truth.
|
// Zero asserts that i is the zero value for its type and returns the truth.
|
||||||
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
|
||||||
Zero(a.t, i, msgAndArgs...)
|
Zero(a.t, i, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) {
|
||||||
|
Zerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
|
|
2
vendor/github.com/stretchr/testify/require/requirements.go
generated
vendored
2
vendor/github.com/stretchr/testify/require/requirements.go
generated
vendored
|
@ -6,4 +6,4 @@ type TestingT interface {
|
||||||
FailNow()
|
FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl
|
//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl -include-format-funcs
|
||||||
|
|
21
vendor/github.com/stretchr/testify/suite/suite.go
generated
vendored
21
vendor/github.com/stretchr/testify/suite/suite.go
generated
vendored
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var allTestsFilter = func(_, _ string) (bool, error) { return true, nil }
|
||||||
var matchMethod = flag.String("testify.m", "", "regular expression to select tests of the testify suite to run")
|
var matchMethod = flag.String("testify.m", "", "regular expression to select tests of the testify suite to run")
|
||||||
|
|
||||||
// Suite is a basic testing suite with methods for storing and
|
// Suite is a basic testing suite with methods for storing and
|
||||||
|
@ -104,10 +105,20 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||||
tests = append(tests, test)
|
tests = append(tests, test)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
runTests(t, tests)
|
||||||
|
}
|
||||||
|
|
||||||
if !testing.RunTests(func(_, _ string) (bool, error) { return true, nil },
|
func runTests(t testing.TB, tests []testing.InternalTest) {
|
||||||
tests) {
|
r, ok := t.(runner)
|
||||||
t.Fail()
|
if !ok { // backwards compatibility with Go 1.6 and below
|
||||||
|
if !testing.RunTests(allTestsFilter, tests) {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
r.Run(test.Name, test.F)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,3 +130,7 @@ func methodFilter(name string) (bool, error) {
|
||||||
}
|
}
|
||||||
return regexp.MatchString(*matchMethod, name)
|
return regexp.MatchString(*matchMethod, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type runner interface {
|
||||||
|
Run(name string, f func(t *testing.T)) bool
|
||||||
|
}
|
||||||
|
|
18
vendor/github.com/stretchr/testify/suite/suite_test.go
generated
vendored
18
vendor/github.com/stretchr/testify/suite/suite_test.go
generated
vendored
|
@ -8,6 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SuiteRequireTwice is intended to test the usage of suite.Require in two
|
// SuiteRequireTwice is intended to test the usage of suite.Require in two
|
||||||
|
@ -19,7 +20,7 @@ type SuiteRequireTwice struct{ Suite }
|
||||||
// A regression would result on these tests panicking rather than failing.
|
// A regression would result on these tests panicking rather than failing.
|
||||||
func TestSuiteRequireTwice(t *testing.T) {
|
func TestSuiteRequireTwice(t *testing.T) {
|
||||||
ok := testing.RunTests(
|
ok := testing.RunTests(
|
||||||
func(_, _ string) (bool, error) { return true, nil },
|
allTestsFilter,
|
||||||
[]testing.InternalTest{{
|
[]testing.InternalTest{{
|
||||||
Name: "TestSuiteRequireTwice",
|
Name: "TestSuiteRequireTwice",
|
||||||
F: func(t *testing.T) {
|
F: func(t *testing.T) {
|
||||||
|
@ -267,16 +268,19 @@ func (sc *StdoutCapture) StopCapture() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSuiteLogging(t *testing.T) {
|
func TestSuiteLogging(t *testing.T) {
|
||||||
testT := testing.T{}
|
|
||||||
|
|
||||||
suiteLoggingTester := new(SuiteLoggingTester)
|
suiteLoggingTester := new(SuiteLoggingTester)
|
||||||
|
|
||||||
capture := StdoutCapture{}
|
capture := StdoutCapture{}
|
||||||
|
internalTest := testing.InternalTest{
|
||||||
|
Name: "SomeTest",
|
||||||
|
F: func(subT *testing.T) {
|
||||||
|
Run(subT, suiteLoggingTester)
|
||||||
|
},
|
||||||
|
}
|
||||||
capture.StartCapture()
|
capture.StartCapture()
|
||||||
Run(&testT, suiteLoggingTester)
|
testing.RunTests(allTestsFilter, []testing.InternalTest{internalTest})
|
||||||
output, err := capture.StopCapture()
|
output, err := capture.StopCapture()
|
||||||
|
require.NoError(t, err, "Got an error trying to capture stdout and stderr!")
|
||||||
assert.Nil(t, err, "Got an error trying to capture stdout!")
|
require.NotEmpty(t, output, "output content must not be empty")
|
||||||
|
|
||||||
// Failed tests' output is always printed
|
// Failed tests' output is always printed
|
||||||
assert.Contains(t, output, "TESTLOGFAIL")
|
assert.Contains(t, output, "TESTLOGFAIL")
|
||||||
|
|
Loading…
Reference in a new issue