summaryrefslogtreecommitdiff
path: root/vendor/github.com/stretchr/testify
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2017-12-05 08:10:13 -0500
committerDave Henderson <dhenderson@gmail.com>2017-12-05 08:10:13 -0500
commit149f2b13d110f34f048e5942466faea4e1a4a870 (patch)
tree41a259362fefcfc99f95b26fda532a26fd4ba4f0 /vendor/github.com/stretchr/testify
parentf6e20ca5ecb47c067fccca8d61e937f35348e7a5 (diff)
Pruning dependencies with `dep prune`
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'vendor/github.com/stretchr/testify')
-rw-r--r--vendor/github.com/stretchr/testify/Godeps/Godeps.json23
-rw-r--r--vendor/github.com/stretchr/testify/Godeps/Readme5
-rw-r--r--vendor/github.com/stretchr/testify/_codegen/main.go287
-rw-r--r--vendor/github.com/stretchr/testify/http/doc.go2
-rw-r--r--vendor/github.com/stretchr/testify/http/test_response_writer.go49
-rw-r--r--vendor/github.com/stretchr/testify/http/test_round_tripper.go17
-rw-r--r--vendor/github.com/stretchr/testify/mock/doc.go44
-rw-r--r--vendor/github.com/stretchr/testify/mock/mock.go763
-rw-r--r--vendor/github.com/stretchr/testify/mock/mock_test.go1132
-rw-r--r--vendor/github.com/stretchr/testify/require/doc.go28
-rw-r--r--vendor/github.com/stretchr/testify/require/forward_requirements.go16
-rw-r--r--vendor/github.com/stretchr/testify/require/forward_requirements_test.go385
-rw-r--r--vendor/github.com/stretchr/testify/require/require.go464
-rw-r--r--vendor/github.com/stretchr/testify/require/require.go.tmpl6
-rw-r--r--vendor/github.com/stretchr/testify/require/require_forward.go388
-rw-r--r--vendor/github.com/stretchr/testify/require/require_forward.go.tmpl4
-rw-r--r--vendor/github.com/stretchr/testify/require/requirements.go9
-rw-r--r--vendor/github.com/stretchr/testify/require/requirements_test.go369
-rw-r--r--vendor/github.com/stretchr/testify/suite/doc.go65
-rw-r--r--vendor/github.com/stretchr/testify/suite/interfaces.go34
-rw-r--r--vendor/github.com/stretchr/testify/suite/suite.go115
-rw-r--r--vendor/github.com/stretchr/testify/suite/suite_test.go239
22 files changed, 0 insertions, 4444 deletions
diff --git a/vendor/github.com/stretchr/testify/Godeps/Godeps.json b/vendor/github.com/stretchr/testify/Godeps/Godeps.json
deleted file mode 100644
index df032ac3..00000000
--- a/vendor/github.com/stretchr/testify/Godeps/Godeps.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "ImportPath": "github.com/stretchr/testify",
- "GoVersion": "go1.5",
- "GodepVersion": "v74",
- "Packages": [
- "./..."
- ],
- "Deps": [
- {
- "ImportPath": "github.com/davecgh/go-spew/spew",
- "Comment": "v1.0.0-3-g6d21280",
- "Rev": "6d212800a42e8ab5c146b8ace3490ee17e5225f9"
- },
- {
- "ImportPath": "github.com/pmezard/go-difflib/difflib",
- "Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d"
- },
- {
- "ImportPath": "github.com/stretchr/objx",
- "Rev": "cbeaeb16a013161a98496fad62933b1d21786672"
- }
- ]
-}
diff --git a/vendor/github.com/stretchr/testify/Godeps/Readme b/vendor/github.com/stretchr/testify/Godeps/Readme
deleted file mode 100644
index 4cdaa53d..00000000
--- a/vendor/github.com/stretchr/testify/Godeps/Readme
+++ /dev/null
@@ -1,5 +0,0 @@
-This directory tree is generated automatically by godep.
-
-Please do not edit.
-
-See https://github.com/tools/godep for more information.
diff --git a/vendor/github.com/stretchr/testify/_codegen/main.go b/vendor/github.com/stretchr/testify/_codegen/main.go
deleted file mode 100644
index 328009f8..00000000
--- a/vendor/github.com/stretchr/testify/_codegen/main.go
+++ /dev/null
@@ -1,287 +0,0 @@
-// This program reads all assertion functions from the assert package and
-// automatically generates the corersponding requires and forwarded assertions
-
-package main
-
-import (
- "bytes"
- "flag"
- "fmt"
- "go/ast"
- "go/build"
- "go/doc"
- "go/importer"
- "go/parser"
- "go/token"
- "go/types"
- "io"
- "io/ioutil"
- "log"
- "os"
- "path"
- "strings"
- "text/template"
-
- "github.com/ernesto-jimenez/gogen/imports"
-)
-
-var (
- pkg = flag.String("assert-path", "github.com/stretchr/testify/assert", "Path to the assert package")
- outputPkg = flag.String("output-package", "", "package for the resulting code")
- tmplFile = flag.String("template", "", "What file to load the function template from")
- out = flag.String("out", "", "What file to write the source code to")
-)
-
-func main() {
- flag.Parse()
-
- scope, docs, err := parsePackageSource(*pkg)
- if err != nil {
- log.Fatal(err)
- }
-
- importer, funcs, err := analyzeCode(scope, docs)
- if err != nil {
- log.Fatal(err)
- }
-
- if err := generateCode(importer, funcs); err != nil {
- log.Fatal(err)
- }
-}
-
-func generateCode(importer imports.Importer, funcs []testFunc) error {
- buff := bytes.NewBuffer(nil)
-
- tmplHead, tmplFunc, err := parseTemplates()
- if err != nil {
- return err
- }
-
- // Generate header
- if err := tmplHead.Execute(buff, struct {
- Name string
- Imports map[string]string
- }{
- *outputPkg,
- importer.Imports(),
- }); err != nil {
- return err
- }
-
- // Generate funcs
- for _, fn := range funcs {
- buff.Write([]byte("\n\n"))
- if err := tmplFunc.Execute(buff, &fn); err != nil {
- return err
- }
- }
-
- // Write file
- output, err := outputFile()
- if err != nil {
- return err
- }
- defer output.Close()
- _, err = io.Copy(output, buff)
- return err
-}
-
-func parseTemplates() (*template.Template, *template.Template, error) {
- tmplHead, err := template.New("header").Parse(headerTemplate)
- if err != nil {
- return nil, nil, err
- }
- if *tmplFile != "" {
- f, err := ioutil.ReadFile(*tmplFile)
- if err != nil {
- return nil, nil, err
- }
- funcTemplate = string(f)
- }
- tmpl, err := template.New("function").Parse(funcTemplate)
- if err != nil {
- return nil, nil, err
- }
- return tmplHead, tmpl, nil
-}
-
-func outputFile() (*os.File, error) {
- filename := *out
- if filename == "-" || (filename == "" && *tmplFile == "") {
- return os.Stdout, nil
- }
- if filename == "" {
- filename = strings.TrimSuffix(strings.TrimSuffix(*tmplFile, ".tmpl"), ".go") + ".go"
- }
- return os.Create(filename)
-}
-
-// analyzeCode takes the types scope and the docs and returns the import
-// information and information about all the assertion functions.
-func analyzeCode(scope *types.Scope, docs *doc.Package) (imports.Importer, []testFunc, error) {
- testingT := scope.Lookup("TestingT").Type().Underlying().(*types.Interface)
-
- importer := imports.New(*outputPkg)
- var funcs []testFunc
- // Go through all the top level functions
- for _, fdocs := range docs.Funcs {
- // Find the function
- obj := scope.Lookup(fdocs.Name)
-
- fn, ok := obj.(*types.Func)
- if !ok {
- continue
- }
- // Check function signatuer has at least two arguments
- sig := fn.Type().(*types.Signature)
- if sig.Params().Len() < 2 {
- continue
- }
- // Check first argument is of type testingT
- first, ok := sig.Params().At(0).Type().(*types.Named)
- if !ok {
- continue
- }
- firstType, ok := first.Underlying().(*types.Interface)
- if !ok {
- continue
- }
- if !types.Implements(firstType, testingT) {
- continue
- }
-
- funcs = append(funcs, testFunc{*outputPkg, fdocs, fn})
- importer.AddImportsFrom(sig.Params())
- }
- return importer, funcs, nil
-}
-
-// parsePackageSource returns the types scope and the package documentation from the pa
-func parsePackageSource(pkg string) (*types.Scope, *doc.Package, error) {
- pd, err := build.Import(pkg, ".", 0)
- if err != nil {
- return nil, nil, err
- }
-
- fset := token.NewFileSet()
- files := make(map[string]*ast.File)
- fileList := make([]*ast.File, len(pd.GoFiles))
- for i, fname := range pd.GoFiles {
- src, err := ioutil.ReadFile(path.Join(pd.SrcRoot, pd.ImportPath, fname))
- if err != nil {
- return nil, nil, err
- }
- f, err := parser.ParseFile(fset, fname, src, parser.ParseComments|parser.AllErrors)
- if err != nil {
- return nil, nil, err
- }
- files[fname] = f
- fileList[i] = f
- }
-
- cfg := types.Config{
- Importer: importer.Default(),
- }
- info := types.Info{
- Defs: make(map[*ast.Ident]types.Object),
- }
- tp, err := cfg.Check(pkg, fset, fileList, &info)
- if err != nil {
- return nil, nil, err
- }
-
- scope := tp.Scope()
-
- ap, _ := ast.NewPackage(fset, files, nil, nil)
- docs := doc.New(ap, pkg, 0)
-
- return scope, docs, nil
-}
-
-type testFunc struct {
- CurrentPkg string
- DocInfo *doc.Func
- TypeInfo *types.Func
-}
-
-func (f *testFunc) Qualifier(p *types.Package) string {
- if p == nil || p.Name() == f.CurrentPkg {
- return ""
- }
- return p.Name()
-}
-
-func (f *testFunc) Params() string {
- sig := f.TypeInfo.Type().(*types.Signature)
- params := sig.Params()
- p := ""
- comma := ""
- to := params.Len()
- var i int
-
- if sig.Variadic() {
- to--
- }
- for i = 1; i < to; i++ {
- param := params.At(i)
- p += fmt.Sprintf("%s%s %s", comma, param.Name(), types.TypeString(param.Type(), f.Qualifier))
- comma = ", "
- }
- if sig.Variadic() {
- param := params.At(params.Len() - 1)
- p += fmt.Sprintf("%s%s ...%s", comma, param.Name(), types.TypeString(param.Type().(*types.Slice).Elem(), f.Qualifier))
- }
- return p
-}
-
-func (f *testFunc) ForwardedParams() string {
- sig := f.TypeInfo.Type().(*types.Signature)
- params := sig.Params()
- p := ""
- comma := ""
- to := params.Len()
- var i int
-
- if sig.Variadic() {
- to--
- }
- for i = 1; i < to; i++ {
- param := params.At(i)
- p += fmt.Sprintf("%s%s", comma, param.Name())
- comma = ", "
- }
- if sig.Variadic() {
- param := params.At(params.Len() - 1)
- p += fmt.Sprintf("%s%s...", comma, param.Name())
- }
- return p
-}
-
-func (f *testFunc) Comment() string {
- return "// " + strings.Replace(strings.TrimSpace(f.DocInfo.Doc), "\n", "\n// ", -1)
-}
-
-func (f *testFunc) CommentWithoutT(receiver string) string {
- search := fmt.Sprintf("assert.%s(t, ", f.DocInfo.Name)
- replace := fmt.Sprintf("%s.%s(", receiver, f.DocInfo.Name)
- return strings.Replace(f.Comment(), search, replace, -1)
-}
-
-var headerTemplate = `/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
-*/
-
-package {{.Name}}
-
-import (
-{{range $path, $name := .Imports}}
- {{$name}} "{{$path}}"{{end}}
-)
-`
-
-var funcTemplate = `{{.Comment}}
-func (fwd *AssertionsForwarder) {{.DocInfo.Name}}({{.Params}}) bool {
- return assert.{{.DocInfo.Name}}({{.ForwardedParams}})
-}`
diff --git a/vendor/github.com/stretchr/testify/http/doc.go b/vendor/github.com/stretchr/testify/http/doc.go
deleted file mode 100644
index 695167c6..00000000
--- a/vendor/github.com/stretchr/testify/http/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package http DEPRECATED USE net/http/httptest
-package http
diff --git a/vendor/github.com/stretchr/testify/http/test_response_writer.go b/vendor/github.com/stretchr/testify/http/test_response_writer.go
deleted file mode 100644
index 5c3f813f..00000000
--- a/vendor/github.com/stretchr/testify/http/test_response_writer.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package http
-
-import (
- "net/http"
-)
-
-// TestResponseWriter DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead.
-type TestResponseWriter struct {
-
- // StatusCode is the last int written by the call to WriteHeader(int)
- StatusCode int
-
- // Output is a string containing the written bytes using the Write([]byte) func.
- Output string
-
- // header is the internal storage of the http.Header object
- header http.Header
-}
-
-// Header DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead.
-func (rw *TestResponseWriter) Header() http.Header {
-
- if rw.header == nil {
- rw.header = make(http.Header)
- }
-
- return rw.header
-}
-
-// Write DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead.
-func (rw *TestResponseWriter) Write(bytes []byte) (int, error) {
-
- // assume 200 success if no header has been set
- if rw.StatusCode == 0 {
- rw.WriteHeader(200)
- }
-
- // add these bytes to the output string
- rw.Output = rw.Output + string(bytes)
-
- // return normal values
- return 0, nil
-
-}
-
-// WriteHeader DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead.
-func (rw *TestResponseWriter) WriteHeader(i int) {
- rw.StatusCode = i
-}
diff --git a/vendor/github.com/stretchr/testify/http/test_round_tripper.go b/vendor/github.com/stretchr/testify/http/test_round_tripper.go
deleted file mode 100644
index b1e32f1d..00000000
--- a/vendor/github.com/stretchr/testify/http/test_round_tripper.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package http
-
-import (
- "github.com/stretchr/testify/mock"
- "net/http"
-)
-
-// TestRoundTripper DEPRECATED USE net/http/httptest
-type TestRoundTripper struct {
- mock.Mock
-}
-
-// RoundTrip DEPRECATED USE net/http/httptest
-func (t *TestRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
- args := t.Called(req)
- return args.Get(0).(*http.Response), args.Error(1)
-}
diff --git a/vendor/github.com/stretchr/testify/mock/doc.go b/vendor/github.com/stretchr/testify/mock/doc.go
deleted file mode 100644
index 7324128e..00000000
--- a/vendor/github.com/stretchr/testify/mock/doc.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Package mock provides a system by which it is possible to mock your objects
-// and verify calls are happening as expected.
-//
-// Example Usage
-//
-// The mock package provides an object, Mock, that tracks activity on another object. It is usually
-// embedded into a test object as shown below:
-//
-// type MyTestObject struct {
-// // add a Mock object instance
-// mock.Mock
-//
-// // other fields go here as normal
-// }
-//
-// When implementing the methods of an interface, you wire your functions up
-// to call the Mock.Called(args...) method, and return the appropriate values.
-//
-// For example, to mock a method that saves the name and age of a person and returns
-// the year of their birth or an error, you might write this:
-//
-// func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) {
-// args := o.Called(firstname, lastname, age)
-// return args.Int(0), args.Error(1)
-// }
-//
-// The Int, Error and Bool methods are examples of strongly typed getters that take the argument
-// index position. Given this argument list:
-//
-// (12, true, "Something")
-//
-// You could read them out strongly typed like this:
-//
-// args.Int(0)
-// args.Bool(1)
-// args.String(2)
-//
-// For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion:
-//
-// return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine)
-//
-// This may cause a panic if the object you are getting is nil (the type assertion will fail), in those
-// cases you should check for nil first.
-package mock
diff --git a/vendor/github.com/stretchr/testify/mock/mock.go b/vendor/github.com/stretchr/testify/mock/mock.go
deleted file mode 100644
index 20d7b8b1..00000000
--- a/vendor/github.com/stretchr/testify/mock/mock.go
+++ /dev/null
@@ -1,763 +0,0 @@
-package mock
-
-import (
- "fmt"
- "reflect"
- "regexp"
- "runtime"
- "strings"
- "sync"
- "time"
-
- "github.com/davecgh/go-spew/spew"
- "github.com/pmezard/go-difflib/difflib"
- "github.com/stretchr/objx"
- "github.com/stretchr/testify/assert"
-)
-
-func inin() {
- spew.Config.SortKeys = true
-}
-
-// TestingT is an interface wrapper around *testing.T
-type TestingT interface {
- Logf(format string, args ...interface{})
- Errorf(format string, args ...interface{})
- FailNow()
-}
-
-/*
- Call
-*/
-
-// Call represents a method call and is used for setting expectations,
-// as well as recording activity.
-type Call struct {
- Parent *Mock
-
- // The name of the method that was or will be called.
- Method string
-
- // Holds the arguments of the method.
- Arguments Arguments
-
- // Holds the arguments that should be returned when
- // this method is called.
- ReturnArguments Arguments
-
- // The number of times to return the return arguments when setting
- // expectations. 0 means to always return the value.
- Repeatability int
-
- // Amount of times this call has been called
- totalCalls int
-
- // Holds a channel that will be used to block the Return until it either
- // receives a message or is closed. nil means it returns immediately.
- WaitFor <-chan time.Time
-
- // Holds a handler used to manipulate arguments content that are passed by
- // reference. It's useful when mocking methods such as unmarshalers or
- // decoders.
- RunFn func(Arguments)
-}
-
-func newCall(parent *Mock, methodName string, methodArguments ...interface{}) *Call {
- return &Call{
- Parent: parent,
- Method: methodName,
- Arguments: methodArguments,
- ReturnArguments: make([]interface{}, 0),
- Repeatability: 0,
- WaitFor: nil,
- RunFn: nil,
- }
-}
-
-func (c *Call) lock() {
- c.Parent.mutex.Lock()
-}
-
-func (c *Call) unlock() {
- c.Parent.mutex.Unlock()
-}
-
-// Return specifies the return arguments for the expectation.
-//
-// Mock.On("DoSomething").Return(errors.New("failed"))
-func (c *Call) Return(returnArguments ...interface{}) *Call {
- c.lock()
- defer c.unlock()
-
- c.ReturnArguments = returnArguments
-
- return c
-}
-
-// Once indicates that that the mock should only return the value once.
-//
-// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once()
-func (c *Call) Once() *Call {
- return c.Times(1)
-}
-
-// Twice indicates that that the mock should only return the value twice.
-//
-// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice()
-func (c *Call) Twice() *Call {
- return c.Times(2)
-}
-
-// Times indicates that that the mock should only return the indicated number
-// of times.
-//
-// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5)
-func (c *Call) Times(i int) *Call {
- c.lock()
- defer c.unlock()
- c.Repeatability = i
- return c
-}
-
-// WaitUntil sets the channel that will block the mock's return until its closed
-// or a message is received.
-//
-// Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second))
-func (c *Call) WaitUntil(w <-chan time.Time) *Call {
- c.lock()
- defer c.unlock()
- c.WaitFor = w
- return c
-}
-
-// After sets how long to block until the call returns
-//
-// Mock.On("MyMethod", arg1, arg2).After(time.Second)
-func (c *Call) After(d time.Duration) *Call {
- return c.WaitUntil(time.After(d))
-}
-
-// Run sets a handler to be called before returning. It can be used when
-// mocking a method such as unmarshalers that takes a pointer to a struct and
-// sets properties in such struct
-//
-// Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(func(args Arguments) {
-// arg := args.Get(0).(*map[string]interface{})
-// arg["foo"] = "bar"
-// })
-func (c *Call) Run(fn func(Arguments)) *Call {
- c.lock()
- defer c.unlock()
- c.RunFn = fn
- return c
-}
-
-// On chains a new expectation description onto the mocked interface. This
-// allows syntax like.
-//
-// Mock.
-// On("MyMethod", 1).Return(nil).
-// On("MyOtherMethod", 'a', 'b', 'c').Return(errors.New("Some Error"))
-func (c *Call) On(methodName string, arguments ...interface{}) *Call {
- return c.Parent.On(methodName, arguments...)
-}
-
-// Mock is the workhorse used to track activity on another object.
-// For an example of its usage, refer to the "Example Usage" section at the top
-// of this document.
-type Mock struct {
- // Represents the calls that are expected of
- // an object.
- ExpectedCalls []*Call
-
- // Holds the calls that were made to this mocked object.
- Calls []Call
-
- // TestData holds any data that might be useful for testing. Testify ignores
- // this data completely allowing you to do whatever you like with it.
- testData objx.Map
-
- mutex sync.Mutex
-}
-
-// TestData holds any data that might be useful for testing. Testify ignores
-// this data completely allowing you to do whatever you like with it.
-func (m *Mock) TestData() objx.Map {
-
- if m.testData == nil {
- m.testData = make(objx.Map)
- }
-
- return m.testData
-}
-
-/*
- Setting expectations
-*/
-
-// On starts a description of an expectation of the specified method
-// being called.
-//
-// Mock.On("MyMethod", arg1, arg2)
-func (m *Mock) On(methodName string, arguments ...interface{}) *Call {
- for _, arg := range arguments {
- if v := reflect.ValueOf(arg); v.Kind() == reflect.Func {
- panic(fmt.Sprintf("cannot use Func in expectations. Use mock.AnythingOfType(\"%T\")", arg))
- }
- }
-
- m.mutex.Lock()
- defer m.mutex.Unlock()
- c := newCall(m, methodName, arguments...)
- m.ExpectedCalls = append(m.ExpectedCalls, c)
- return c
-}
-
-// /*
-// Recording and responding to activity
-// */
-
-func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) {
- m.mutex.Lock()
- defer m.mutex.Unlock()
- for i, call := range m.ExpectedCalls {
- if call.Method == method && call.Repeatability > -1 {
-
- _, diffCount := call.Arguments.Diff(arguments)
- if diffCount == 0 {
- return i, call
- }
-
- }
- }
- return -1, nil
-}
-
-func (m *Mock) findClosestCall(method string, arguments ...interface{}) (bool, *Call) {
- diffCount := 0
- var closestCall *Call
-
- for _, call := range m.expectedCalls() {
- if call.Method == method {
-
- _, tempDiffCount := call.Arguments.Diff(arguments)
- if tempDiffCount < diffCount || diffCount == 0 {
- diffCount = tempDiffCount
- closestCall = call
- }
-
- }
- }
-
- if closestCall == nil {
- return false, nil
- }
-
- return true, closestCall
-}
-
-func callString(method string, arguments Arguments, includeArgumentValues bool) string {
-
- var argValsString string
- if includeArgumentValues {
- var argVals []string
- for argIndex, arg := range arguments {
- argVals = append(argVals, fmt.Sprintf("%d: %#v", argIndex, arg))
- }
- argValsString = fmt.Sprintf("\n\t\t%s", strings.Join(argVals, "\n\t\t"))
- }
-
- return fmt.Sprintf("%s(%s)%s", method, arguments.String(), argValsString)
-}
-
-// Called tells the mock object that a method has been called, and gets an array
-// of arguments to return. Panics if the call is unexpected (i.e. not preceded by
-// appropriate .On .Return() calls)
-// If Call.WaitFor is set, blocks until the channel is closed or receives a message.
-func (m *Mock) Called(arguments ...interface{}) Arguments {
- // get the calling function's name
- pc, _, _, ok := runtime.Caller(1)
- if !ok {
- panic("Couldn't get the caller information")
- }
- functionPath := runtime.FuncForPC(pc).Name()
- //Next four lines are required to use GCCGO function naming conventions.
- //For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
- //uses inteface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
- //With GCCGO we need to remove interface information starting from pN<dd>.
- re := regexp.MustCompile("\\.pN\\d+_")
- if re.MatchString(functionPath) {
- functionPath = re.Split(functionPath, -1)[0]
- }
- parts := strings.Split(functionPath, ".")
- functionName := parts[len(parts)-1]
-
- found, call := m.findExpectedCall(functionName, arguments...)
-
- if found < 0 {
- // we have to fail here - because we don't know what to do
- // as the return arguments. This is because:
- //
- // a) this is a totally unexpected call to this method,
- // b) the arguments are not what was expected, or
- // c) the developer has forgotten to add an accompanying On...Return pair.
-
- closestFound, closestCall := m.findClosestCall(functionName, arguments...)
-
- if closestFound {
- panic(fmt.Sprintf("\n\nmock: Unexpected Method Call\n-----------------------------\n\n%s\n\nThe closest call I have is: \n\n%s\n\n%s\n", callString(functionName, arguments, true), callString(functionName, closestCall.Arguments, true), diffArguments(arguments, closestCall.Arguments)))
- } else {
- panic(fmt.Sprintf("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(\"%s\").Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", functionName, functionName, callString(functionName, arguments, true), assert.CallerInfo()))
- }
- } else {
- m.mutex.Lock()
- switch {
- case call.Repeatability == 1:
- call.Repeatability = -1
- call.totalCalls++
-
- case call.Repeatability > 1:
- call.Repeatability--
- call.totalCalls++
-
- case call.Repeatability == 0:
- call.totalCalls++
- }
- m.mutex.Unlock()
- }
-
- // add the call
- m.mutex.Lock()
- m.Calls = append(m.Calls, *newCall(m, functionName, arguments...))
- m.mutex.Unlock()
-
- // block if specified
- if call.WaitFor != nil {
- <-call.WaitFor
- }
-
- if call.RunFn != nil {
- call.RunFn(arguments)
- }
-
- return call.ReturnArguments
-}
-
-/*
- Assertions
-*/
-
-type assertExpectationser interface {
- AssertExpectations(TestingT) bool
-}
-
-// AssertExpectationsForObjects asserts that everything specified with On and Return
-// of the specified objects was in fact called as expected.
-//
-// Calls may have occurred in any order.
-func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool {
- for _, obj := range testObjects {
- if m, ok := obj.(Mock); ok {
- t.Logf("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)")
- obj = &m
- }
- m := obj.(assertExpectationser)
- if !m.AssertExpectations(t) {
- return false
- }
- }
- return true
-}
-
-// AssertExpectations asserts that everything specified with On and Return was
-// in fact called as expected. Calls may have occurred in any order.
-func (m *Mock) AssertExpectations(t TestingT) bool {
- var somethingMissing bool
- var failedExpectations int
-
- // iterate through each expectation
- expectedCalls := m.expectedCalls()
- for _, expectedCall := range expectedCalls {
- if !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments) && expectedCall.totalCalls == 0 {
- somethingMissing = true
- failedExpectations++
- t.Logf("\u274C\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
- } else {
- m.mutex.Lock()
- if expectedCall.Repeatability > 0 {
- somethingMissing = true
- failedExpectations++
- } else {
- t.Logf("\u2705\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
- }
- m.mutex.Unlock()
- }
- }
-
- if somethingMissing {
- t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe code you are testing needs to make %d more call(s).\n\tat: %s", len(expectedCalls)-failedExpectations, len(expectedCalls), failedExpectations, assert.CallerInfo())
- }
-
- return !somethingMissing
-}
-
-// AssertNumberOfCalls asserts that the method was called expectedCalls times.
-func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool {
- var actualCalls int
- for _, call := range m.calls() {
- if call.Method == methodName {
- actualCalls++
- }
- }
- return assert.Equal(t, expectedCalls, actualCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls))
-}
-
-// AssertCalled asserts that the method was called.
-// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
-func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool {
- if !assert.True(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method should have been called with %d argument(s), but was not.", methodName, len(arguments))) {
- t.Logf("%v", m.expectedCalls())
- return false
- }
- return true
-}
-
-// AssertNotCalled asserts that the method was not called.
-// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
-func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool {
- if !assert.False(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method was called with %d argument(s), but should NOT have been.", methodName, len(arguments))) {
- t.Logf("%v", m.expectedCalls())
- return false
- }
- return true
-}
-
-func (m *Mock) methodWasCalled(methodName string, expected []interface{}) bool {
- for _, call := range m.calls() {
- if call.Method == methodName {
-
- _, differences := Arguments(expected).Diff(call.Arguments)
-
- if differences == 0 {
- // found the expected call
- return true
- }
-
- }
- }
- // we didn't find the expected call
- return false
-}
-
-func (m *Mock) expectedCalls() []*Call {
- m.mutex.Lock()
- defer m.mutex.Unlock()
- return append([]*Call{}, m.ExpectedCalls...)
-}
-
-func (m *Mock) calls() []Call {
- m.mutex.Lock()
- defer m.mutex.Unlock()
- return append([]Call{}, m.Calls...)
-}
-
-/*
- Arguments
-*/
-
-// Arguments holds an array of method arguments or return values.
-type Arguments []interface{}
-
-const (
- // Anything is used in Diff and Assert when the argument being tested
- // shouldn't be taken into consideration.
- Anything string = "mock.Anything"
-)
-
-// AnythingOfTypeArgument is a string that contains the type of an argument
-// for use when type checking. Used in Diff and Assert.
-type AnythingOfTypeArgument string
-
-// AnythingOfType returns an AnythingOfTypeArgument object containing the
-// name of the type to check for. Used in Diff and Assert.
-//
-// For example:
-// Assert(t, AnythingOfType("string"), AnythingOfType("int"))
-func AnythingOfType(t string) AnythingOfTypeArgument {
- return AnythingOfTypeArgument(t)
-}
-
-// argumentMatcher performs custom argument matching, returning whether or
-// not the argument is matched by the expectation fixture function.
-type argumentMatcher struct {
- // fn is a function which accepts one argument, and returns a bool.
- fn reflect.Value
-}
-
-func (f argumentMatcher) Matches(argument interface{}) bool {
- expectType := f.fn.Type().In(0)
-
- if reflect.TypeOf(argument).AssignableTo(expectType) {
- result := f.fn.Call([]reflect.Value{reflect.ValueOf(argument)})
- return result[0].Bool()
- }
- return false
-}
-
-func (f argumentMatcher) String() string {
- return fmt.Sprintf("func(%s) bool", f.fn.Type().In(0).Name())
-}
-
-// MatchedBy can be used to match a mock call based on only certain properties
-// from a complex struct or some calculation. It takes a function that will be
-// evaluated with the called argument and will return true when there's a match
-// and false otherwise.
-//
-// Example:
-// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
-//
-// |fn|, must be a function accepting a single argument (of the expected type)
-// which returns a bool. If |fn| doesn't match the required signature,
-// MathedBy() panics.
-func MatchedBy(fn interface{}) argumentMatcher {
- fnType := reflect.TypeOf(fn)
-
- if fnType.Kind() != reflect.Func {
- panic(fmt.Sprintf("assert: arguments: %s is not a func", fn))
- }
- if fnType.NumIn() != 1 {
- panic(fmt.Sprintf("assert: arguments: %s does not take exactly one argument", fn))
- }
- if fnType.NumOut() != 1 || fnType.Out(0).Kind() != reflect.Bool {
- panic(fmt.Sprintf("assert: arguments: %s does not return a bool", fn))
- }
-
- return argumentMatcher{fn: reflect.ValueOf(fn)}
-}
-
-// Get Returns the argument at the specified index.
-func (args Arguments) Get(index int) interface{} {
- if index+1 > len(args) {
- panic(fmt.Sprintf("assert: arguments: Cannot call Get(%d) because there are %d argument(s).", index, len(args)))
- }
- return args[index]
-}
-
-// Is gets whether the objects match the arguments specified.
-func (args Arguments) Is(objects ...interface{}) bool {
- for i, obj := range args {
- if obj != objects[i] {
- return false
- }
- }
- return true
-}
-
-// Diff gets a string describing the differences between the arguments
-// and the specified objects.
-//
-// Returns the diff string and number of differences found.
-func (args Arguments) Diff(objects []interface{}) (string, int) {
-
- var output = "\n"
- var differences int
-
- var maxArgCount = len(args)
- if len(objects) > maxArgCount {
- maxArgCount = len(objects)
- }
-
- for i := 0; i < maxArgCount; i++ {
- var actual, expected interface{}
-
- if len(objects) <= i {
- actual = "(Missing)"
- } else {
- actual = objects[i]
- }
-
- if len(args) <= i {
- expected = "(Missing)"
- } else {
- expected = args[i]
- }
-
- if matcher, ok := expected.(argumentMatcher); ok {
- if matcher.Matches(actual) {
- output = fmt.Sprintf("%s\t%d: \u2705 %s matched by %s\n", output, i, actual, matcher)
- } else {
- differences++
- output = fmt.Sprintf("%s\t%d: \u2705 %s not matched by %s\n", output, i, actual, matcher)
- }
- } else if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() {
-
- // type checking
- if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) {
- // not match
- differences++
- output = fmt.Sprintf("%s\t%d: \u274C type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actual)
- }
-
- } else {
-
- // normal checking
-
- if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) {
- // match
- output = fmt.Sprintf("%s\t%d: \u2705 %s == %s\n", output, i, actual, expected)
- } else {
- // not match
- differences++
- output = fmt.Sprintf("%s\t%d: \u274C %s != %s\n", output, i, actual, expected)
- }
- }
-
- }
-
- if differences == 0 {
- return "No differences.", differences
- }
-
- return output, differences
-
-}
-
-// Assert compares the arguments with the specified objects and fails if
-// they do not exactly match.
-func (args Arguments) Assert(t TestingT, objects ...interface{}) bool {
-
- // get the differences
- diff, diffCount := args.Diff(objects)
-
- if diffCount == 0 {
- return true
- }
-
- // there are differences... report them...
- t.Logf(diff)
- t.Errorf("%sArguments do not match.", assert.CallerInfo())
-
- return false
-
-}
-
-// String gets the argument at the specified index. Panics if there is no argument, or
-// if the argument is of the wrong type.
-//
-// If no index is provided, String() returns a complete string representation
-// of the arguments.
-func (args Arguments) String(indexOrNil ...int) string {
-
- if len(indexOrNil) == 0 {
- // normal String() method - return a string representation of the args
- var argsStr []string
- for _, arg := range args {
- argsStr = append(argsStr, fmt.Sprintf("%s", reflect.TypeOf(arg)))
- }
- return strings.Join(argsStr, ",")
- } else if len(indexOrNil) == 1 {
- // Index has been specified - get the argument at that index
- var index = indexOrNil[0]
- var s string
- var ok bool
- if s, ok = args.Get(index).(string); !ok {
- panic(fmt.Sprintf("assert: arguments: String(%d) failed because object wasn't correct type: %s", index, args.Get(index)))
- }
- return s
- }
-
- panic(fmt.Sprintf("assert: arguments: Wrong number of arguments passed to String. Must be 0 or 1, not %d", len(indexOrNil)))
-
-}
-
-// Int gets the argument at the specified index. Panics if there is no argument, or
-// if the argument is of the wrong type.
-func (args Arguments) Int(index int) int {
- var s int
- var ok bool
- if s, ok = args.Get(index).(int); !ok {
- panic(fmt.Sprintf("assert: arguments: Int(%d) failed because object wasn't correct type: %v", index, args.Get(index)))
- }
- return s
-}
-
-// Error gets the argument at the specified index. Panics if there is no argument, or
-// if the argument is of the wrong type.
-func (args Arguments) Error(index int) error {
- obj := args.Get(index)
- var s error
- var ok bool
- if obj == nil {
- return nil
- }
- if s, ok = obj.(error); !ok {
- panic(fmt.Sprintf("assert: arguments: Error(%d) failed because object wasn't correct type: %v", index, args.Get(index)))
- }
- return s
-}
-
-// Bool gets the argument at the specified index. Panics if there is no argument, or
-// if the argument is of the wrong type.
-func (args Arguments) Bool(index int) bool {
- var s bool
- var ok bool
- if s, ok = args.Get(index).(bool); !ok {
- panic(fmt.Sprintf("assert: arguments: Bool(%d) failed because object wasn't correct type: %v", index, args.Get(index)))
- }
- return s
-}
-
-func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) {
- t := reflect.TypeOf(v)
- k := t.Kind()
-
- if k == reflect.Ptr {
- t = t.Elem()
- k = t.Kind()
- }
- return t, k
-}
-
-func diffArguments(expected Arguments, actual Arguments) string {
- for x := range expected {
- if diffString := diff(expected[x], actual[x]); diffString != "" {
- return fmt.Sprintf("Difference found in argument %v:\n\n%s", x, diffString)
- }
- }
-
- return ""
-}
-
-// diff returns a diff of both values as long as both are of the same type and
-// are a struct, map, slice or array. Otherwise it returns an empty string.
-func diff(expected interface{}, actual interface{}) string {
- if expected == nil || actual == nil {
- return ""
- }
-
- et, ek := typeAndKind(expected)
- at, _ := typeAndKind(actual)
-
- if et != at {
- return ""
- }
-
- if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array {
- return ""
- }
-
- e := spew.Sdump(expected)
- a := spew.Sdump(actual)
-
- diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
- A: difflib.SplitLines(e),
- B: difflib.SplitLines(a),
- FromFile: "Expected",
- FromDate: "",
- ToFile: "Actual",
- ToDate: "",
- Context: 1,
- })
-
- return diff
-}
diff --git a/vendor/github.com/stretchr/testify/mock/mock_test.go b/vendor/github.com/stretchr/testify/mock/mock_test.go
deleted file mode 100644
index 8cb4615d..00000000
--- a/vendor/github.com/stretchr/testify/mock/mock_test.go
+++ /dev/null
@@ -1,1132 +0,0 @@
-package mock
-
-import (
- "errors"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "testing"
- "time"
-)
-
-/*
- Test objects
-*/
-
-// ExampleInterface represents an example interface.
-type ExampleInterface interface {
- TheExampleMethod(a, b, c int) (int, error)
-}
-
-// TestExampleImplementation is a test implementation of ExampleInterface
-type TestExampleImplementation struct {
- Mock
-}
-
-func (i *TestExampleImplementation) TheExampleMethod(a, b, c int) (int, error) {
- args := i.Called(a, b, c)
- return args.Int(0), errors.New("Whoops")
-}
-
-func (i *TestExampleImplementation) TheExampleMethod2(yesorno bool) {
- i.Called(yesorno)
-}
-
-type ExampleType struct {
- ran bool
-}
-
-func (i *TestExampleImplementation) TheExampleMethod3(et *ExampleType) error {
- args := i.Called(et)
- return args.Error(0)
-}
-
-func (i *TestExampleImplementation) TheExampleMethodFunc(fn func(string) error) error {
- args := i.Called(fn)
- return args.Error(0)
-}
-
-func (i *TestExampleImplementation) TheExampleMethodVariadic(a ...int) error {
- args := i.Called(a)
- return args.Error(0)
-}
-
-func (i *TestExampleImplementation) TheExampleMethodVariadicInterface(a ...interface{}) error {
- args := i.Called(a)
- return args.Error(0)
-}
-
-type ExampleFuncType func(string) error
-
-func (i *TestExampleImplementation) TheExampleMethodFuncType(fn ExampleFuncType) error {
- args := i.Called(fn)
- return args.Error(0)
-}
-
-/*
- Mock
-*/
-
-func Test_Mock_TestData(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- if assert.NotNil(t, mockedService.TestData()) {
-
- mockedService.TestData().Set("something", 123)
- assert.Equal(t, 123, mockedService.TestData().Get("something").Data())
- }
-}
-
-func Test_Mock_On(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.On("TheExampleMethod")
- assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
- assert.Equal(t, "TheExampleMethod", c.Method)
-}
-
-func Test_Mock_Chained_On(t *testing.T) {
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- mockedService.
- On("TheExampleMethod", 1, 2, 3).
- Return(0).
- On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).
- Return(nil)
-
- expectedCalls := []*Call{
- &Call{
- Parent: &mockedService.Mock,
- Method: "TheExampleMethod",
- Arguments: []interface{}{1, 2, 3},
- ReturnArguments: []interface{}{0},
- },
- &Call{
- Parent: &mockedService.Mock,
- Method: "TheExampleMethod3",
- Arguments: []interface{}{AnythingOfType("*mock.ExampleType")},
- ReturnArguments: []interface{}{nil},
- },
- }
- assert.Equal(t, expectedCalls, mockedService.ExpectedCalls)
-}
-
-func Test_Mock_On_WithArgs(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.On("TheExampleMethod", 1, 2, 3, 4)
-
- assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
- assert.Equal(t, "TheExampleMethod", c.Method)
- assert.Equal(t, Arguments{1, 2, 3, 4}, c.Arguments)
-}
-
-func Test_Mock_On_WithFuncArg(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.
- On("TheExampleMethodFunc", AnythingOfType("func(string) error")).
- Return(nil)
-
- assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
- assert.Equal(t, "TheExampleMethodFunc", c.Method)
- assert.Equal(t, 1, len(c.Arguments))
- assert.Equal(t, AnythingOfType("func(string) error"), c.Arguments[0])
-
- fn := func(string) error { return nil }
-
- assert.NotPanics(t, func() {
- mockedService.TheExampleMethodFunc(fn)
- })
-}
-
-func Test_Mock_On_WithIntArgMatcher(t *testing.T) {
- var mockedService TestExampleImplementation
-
- mockedService.On("TheExampleMethod",
- MatchedBy(func(a int) bool {
- return a == 1
- }), MatchedBy(func(b int) bool {
- return b == 2
- }), MatchedBy(func(c int) bool {
- return c == 3
- })).Return(0, nil)
-
- assert.Panics(t, func() {
- mockedService.TheExampleMethod(1, 2, 4)
- })
- assert.Panics(t, func() {
- mockedService.TheExampleMethod(2, 2, 3)
- })
- assert.NotPanics(t, func() {
- mockedService.TheExampleMethod(1, 2, 3)
- })
-}
-
-func Test_Mock_On_WithPtrArgMatcher(t *testing.T) {
- var mockedService TestExampleImplementation
-
- mockedService.On("TheExampleMethod3",
- MatchedBy(func(a *ExampleType) bool { return a.ran == true }),
- ).Return(nil)
-
- mockedService.On("TheExampleMethod3",
- MatchedBy(func(a *ExampleType) bool { return a.ran == false }),
- ).Return(errors.New("error"))
-
- assert.Equal(t, mockedService.TheExampleMethod3(&ExampleType{true}), nil)
- assert.EqualError(t, mockedService.TheExampleMethod3(&ExampleType{false}), "error")
-}
-
-func Test_Mock_On_WithFuncArgMatcher(t *testing.T) {
- var mockedService TestExampleImplementation
-
- fixture1, fixture2 := errors.New("fixture1"), errors.New("fixture2")
-
- mockedService.On("TheExampleMethodFunc",
- MatchedBy(func(a func(string) error) bool { return a("string") == fixture1 }),
- ).Return(errors.New("fixture1"))
-
- mockedService.On("TheExampleMethodFunc",
- MatchedBy(func(a func(string) error) bool { return a("string") == fixture2 }),
- ).Return(errors.New("fixture2"))
-
- assert.EqualError(t, mockedService.TheExampleMethodFunc(
- func(string) error { return fixture1 }), "fixture1")
- assert.EqualError(t, mockedService.TheExampleMethodFunc(
- func(string) error { return fixture2 }), "fixture2")
-}
-
-func Test_Mock_On_WithVariadicFunc(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.
- On("TheExampleMethodVariadic", []int{1, 2, 3}).
- Return(nil)
-
- assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
- assert.Equal(t, 1, len(c.Arguments))
- assert.Equal(t, []int{1, 2, 3}, c.Arguments[0])
-
- assert.NotPanics(t, func() {
- mockedService.TheExampleMethodVariadic(1, 2, 3)
- })
- assert.Panics(t, func() {
- mockedService.TheExampleMethodVariadic(1, 2)
- })
-
-}
-
-func Test_Mock_On_WithVariadicFuncWithInterface(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.On("TheExampleMethodVariadicInterface", []interface{}{1, 2, 3}).
- Return(nil)
-
- assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
- assert.Equal(t, 1, len(c.Arguments))
- assert.Equal(t, []interface{}{1, 2, 3}, c.Arguments[0])
-
- assert.NotPanics(t, func() {
- mockedService.TheExampleMethodVariadicInterface(1, 2, 3)
- })
- assert.Panics(t, func() {
- mockedService.TheExampleMethodVariadicInterface(1, 2)
- })
-
-}
-
-func Test_Mock_On_WithVariadicFuncWithEmptyInterfaceArray(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- var expected []interface{}
- c := mockedService.
- On("TheExampleMethodVariadicInterface", expected).
- Return(nil)
-
- assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
- assert.Equal(t, 1, len(c.Arguments))
- assert.Equal(t, expected, c.Arguments[0])
-
- assert.NotPanics(t, func() {
- mockedService.TheExampleMethodVariadicInterface()
- })
- assert.Panics(t, func() {
- mockedService.TheExampleMethodVariadicInterface(1, 2)
- })
-
-}
-
-func Test_Mock_On_WithFuncPanics(t *testing.T) {
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- assert.Panics(t, func() {
- mockedService.On("TheExampleMethodFunc", func(string) error { return nil })
- })
-}
-
-func Test_Mock_On_WithFuncTypeArg(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.
- On("TheExampleMethodFuncType", AnythingOfType("mock.ExampleFuncType")).
- Return(nil)
-
- assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
- assert.Equal(t, 1, len(c.Arguments))
- assert.Equal(t, AnythingOfType("mock.ExampleFuncType"), c.Arguments[0])
-
- fn := func(string) error { return nil }
- assert.NotPanics(t, func() {
- mockedService.TheExampleMethodFuncType(fn)
- })
-}
-
-func Test_Mock_Return(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.
- On("TheExampleMethod", "A", "B", true).
- Return(1, "two", true)
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod", call.Method)
- assert.Equal(t, "A", call.Arguments[0])
- assert.Equal(t, "B", call.Arguments[1])
- assert.Equal(t, true, call.Arguments[2])
- assert.Equal(t, 1, call.ReturnArguments[0])
- assert.Equal(t, "two", call.ReturnArguments[1])
- assert.Equal(t, true, call.ReturnArguments[2])
- assert.Equal(t, 0, call.Repeatability)
- assert.Nil(t, call.WaitFor)
-}
-
-func Test_Mock_Return_WaitUntil(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
- ch := time.After(time.Second)
-
- c := mockedService.Mock.
- On("TheExampleMethod", "A", "B", true).
- WaitUntil(ch).
- Return(1, "two", true)
-
- // assert that the call was created
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod", call.Method)
- assert.Equal(t, "A", call.Arguments[0])
- assert.Equal(t, "B", call.Arguments[1])
- assert.Equal(t, true, call.Arguments[2])
- assert.Equal(t, 1, call.ReturnArguments[0])
- assert.Equal(t, "two", call.ReturnArguments[1])
- assert.Equal(t, true, call.ReturnArguments[2])
- assert.Equal(t, 0, call.Repeatability)
- assert.Equal(t, ch, call.WaitFor)
-}
-
-func Test_Mock_Return_After(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.Mock.
- On("TheExampleMethod", "A", "B", true).
- Return(1, "two", true).
- After(time.Second)
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.Mock.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod", call.Method)
- assert.Equal(t, "A", call.Arguments[0])
- assert.Equal(t, "B", call.Arguments[1])
- assert.Equal(t, true, call.Arguments[2])
- assert.Equal(t, 1, call.ReturnArguments[0])
- assert.Equal(t, "two", call.ReturnArguments[1])
- assert.Equal(t, true, call.ReturnArguments[2])
- assert.Equal(t, 0, call.Repeatability)
- assert.NotEqual(t, nil, call.WaitFor)
-
-}
-
-func Test_Mock_Return_Run(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- fn := func(args Arguments) {
- arg := args.Get(0).(*ExampleType)
- arg.ran = true
- }
-
- c := mockedService.Mock.
- On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).
- Return(nil).
- Run(fn)
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.Mock.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod3", call.Method)
- assert.Equal(t, AnythingOfType("*mock.ExampleType"), call.Arguments[0])
- assert.Equal(t, nil, call.ReturnArguments[0])
- assert.Equal(t, 0, call.Repeatability)
- assert.NotEqual(t, nil, call.WaitFor)
- assert.NotNil(t, call.Run)
-
- et := ExampleType{}
- assert.Equal(t, false, et.ran)
- mockedService.TheExampleMethod3(&et)
- assert.Equal(t, true, et.ran)
-}
-
-func Test_Mock_Return_Run_Out_Of_Order(t *testing.T) {
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
- f := func(args Arguments) {
- arg := args.Get(0).(*ExampleType)
- arg.ran = true
- }
-
- c := mockedService.Mock.
- On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).
- Run(f).
- Return(nil)
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.Mock.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod3", call.Method)
- assert.Equal(t, AnythingOfType("*mock.ExampleType"), call.Arguments[0])
- assert.Equal(t, nil, call.ReturnArguments[0])
- assert.Equal(t, 0, call.Repeatability)
- assert.NotEqual(t, nil, call.WaitFor)
- assert.NotNil(t, call.Run)
-}
-
-func Test_Mock_Return_Once(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.On("TheExampleMethod", "A", "B", true).
- Return(1, "two", true).
- Once()
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod", call.Method)
- assert.Equal(t, "A", call.Arguments[0])
- assert.Equal(t, "B", call.Arguments[1])
- assert.Equal(t, true, call.Arguments[2])
- assert.Equal(t, 1, call.ReturnArguments[0])
- assert.Equal(t, "two", call.ReturnArguments[1])
- assert.Equal(t, true, call.ReturnArguments[2])
- assert.Equal(t, 1, call.Repeatability)
- assert.Nil(t, call.WaitFor)
-}
-
-func Test_Mock_Return_Twice(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.
- On("TheExampleMethod", "A", "B", true).
- Return(1, "two", true).
- Twice()
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod", call.Method)
- assert.Equal(t, "A", call.Arguments[0])
- assert.Equal(t, "B", call.Arguments[1])
- assert.Equal(t, true, call.Arguments[2])
- assert.Equal(t, 1, call.ReturnArguments[0])
- assert.Equal(t, "two", call.ReturnArguments[1])
- assert.Equal(t, true, call.ReturnArguments[2])
- assert.Equal(t, 2, call.Repeatability)
- assert.Nil(t, call.WaitFor)
-}
-
-func Test_Mock_Return_Times(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.
- On("TheExampleMethod", "A", "B", true).
- Return(1, "two", true).
- Times(5)
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod", call.Method)
- assert.Equal(t, "A", call.Arguments[0])
- assert.Equal(t, "B", call.Arguments[1])
- assert.Equal(t, true, call.Arguments[2])
- assert.Equal(t, 1, call.ReturnArguments[0])
- assert.Equal(t, "two", call.ReturnArguments[1])
- assert.Equal(t, true, call.ReturnArguments[2])
- assert.Equal(t, 5, call.Repeatability)
- assert.Nil(t, call.WaitFor)
-}
-
-func Test_Mock_Return_Nothing(t *testing.T) {
-
- // make a test impl object
- var mockedService = new(TestExampleImplementation)
-
- c := mockedService.
- On("TheExampleMethod", "A", "B", true).
- Return()
-
- require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
-
- call := mockedService.ExpectedCalls[0]
-
- assert.Equal(t, "TheExampleMethod", call.Method)
- assert.Equal(t, "A", call.Arguments[0])
- assert.Equal(t, "B", call.Arguments[1])
- assert.Equal(t, true, call.Arguments[2])
- assert.Equal(t, 0, len(call.ReturnArguments))
-}
-
-func Test_Mock_findExpectedCall(t *testing.T) {
-
- m := new(Mock)
- m.On("One", 1).Return("one")
- m.On("Two", 2).Return("two")
- m.On("Two", 3).Return("three")
-
- f, c := m.findExpectedCall("Two", 3)
-
- if assert.Equal(t, 2, f) {
- if assert.NotNil(t, c) {
- assert.Equal(t, "Two", c.Method)
- assert.Equal(t, 3, c.Arguments[0])
- assert.Equal(t, "three", c.ReturnArguments[0])
- }
- }
-
-}
-
-func Test_Mock_findExpectedCall_For_Unknown_Method(t *testing.T) {
-
- m := new(Mock)
- m.On("One", 1).Return("one")
- m.On("Two", 2).Return("two")
- m.On("Two", 3).Return("three")
-
- f, _ := m.findExpectedCall("Two")
-
- assert.Equal(t, -1, f)
-
-}
-
-func Test_Mock_findExpectedCall_Respects_Repeatability(t *testing.T) {
-
- m := new(Mock)
- m.On("One", 1).Return("one")
- m.On("Two", 2).Return("two").Once()
- m.On("Two", 3).Return("three").Twice()
- m.On("Two", 3).Return("three").Times(8)
-
- f, c := m.findExpectedCall("Two", 3)
-
- if assert.Equal(t, 2, f) {
- if assert.NotNil(t, c) {
- assert.Equal(t, "Two", c.Method)
- assert.Equal(t, 3, c.Arguments[0])
- assert.Equal(t, "three", c.ReturnArguments[0])
- }
- }
-
-}
-
-func Test_callString(t *testing.T) {
-
- assert.Equal(t, `Method(int,bool,string)`, callString("Method", []interface{}{1, true, "something"}, false))
-
-}
-
-func Test_Mock_Called(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_Called", 1, 2, 3).Return(5, "6", true)
-
- returnArguments := mockedService.Called(1, 2, 3)
-
- if assert.Equal(t, 1, len(mockedService.Calls)) {
- assert.Equal(t, "Test_Mock_Called", mockedService.Calls[0].Method)
- assert.Equal(t, 1, mockedService.Calls[0].Arguments[0])
- assert.Equal(t, 2, mockedService.Calls[0].Arguments[1])
- assert.Equal(t, 3, mockedService.Calls[0].Arguments[2])
- }
-
- if assert.Equal(t, 3, len(returnArguments)) {
- assert.Equal(t, 5, returnArguments[0])
- assert.Equal(t, "6", returnArguments[1])
- assert.Equal(t, true, returnArguments[2])
- }
-
-}
-
-func asyncCall(m *Mock, ch chan Arguments) {
- ch <- m.Called(1, 2, 3)
-}
-
-func Test_Mock_Called_blocks(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.Mock.On("asyncCall", 1, 2, 3).Return(5, "6", true).After(2 * time.Millisecond)
-
- ch := make(chan Arguments)
-
- go asyncCall(&mockedService.Mock, ch)
-
- select {
- case <-ch:
- t.Fatal("should have waited")
- case <-time.After(1 * time.Millisecond):
- }
-
- returnArguments := <-ch
-
- if assert.Equal(t, 1, len(mockedService.Mock.Calls)) {
- assert.Equal(t, "asyncCall", mockedService.Mock.Calls[0].Method)
- assert.Equal(t, 1, mockedService.Mock.Calls[0].Arguments[0])
- assert.Equal(t, 2, mockedService.Mock.Calls[0].Arguments[1])
- assert.Equal(t, 3, mockedService.Mock.Calls[0].Arguments[2])
- }
-
- if assert.Equal(t, 3, len(returnArguments)) {
- assert.Equal(t, 5, returnArguments[0])
- assert.Equal(t, "6", returnArguments[1])
- assert.Equal(t, true, returnArguments[2])
- }
-
-}
-
-func Test_Mock_Called_For_Bounded_Repeatability(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.
- On("Test_Mock_Called_For_Bounded_Repeatability", 1, 2, 3).
- Return(5, "6", true).
- Once()
- mockedService.
- On("Test_Mock_Called_For_Bounded_Repeatability", 1, 2, 3).
- Return(-1, "hi", false)
-
- returnArguments1 := mockedService.Called(1, 2, 3)
- returnArguments2 := mockedService.Called(1, 2, 3)
-
- if assert.Equal(t, 2, len(mockedService.Calls)) {
- assert.Equal(t, "Test_Mock_Called_For_Bounded_Repeatability", mockedService.Calls[0].Method)
- assert.Equal(t, 1, mockedService.Calls[0].Arguments[0])
- assert.Equal(t, 2, mockedService.Calls[0].Arguments[1])
- assert.Equal(t, 3, mockedService.Calls[0].Arguments[2])
-
- assert.Equal(t, "Test_Mock_Called_For_Bounded_Repeatability", mockedService.Calls[1].Method)
- assert.Equal(t, 1, mockedService.Calls[1].Arguments[0])
- assert.Equal(t, 2, mockedService.Calls[1].Arguments[1])
- assert.Equal(t, 3, mockedService.Calls[1].Arguments[2])
- }
-
- if assert.Equal(t, 3, len(returnArguments1)) {
- assert.Equal(t, 5, returnArguments1[0])
- assert.Equal(t, "6", returnArguments1[1])
- assert.Equal(t, true, returnArguments1[2])
- }
-
- if assert.Equal(t, 3, len(returnArguments2)) {
- assert.Equal(t, -1, returnArguments2[0])
- assert.Equal(t, "hi", returnArguments2[1])
- assert.Equal(t, false, returnArguments2[2])
- }
-
-}
-
-func Test_Mock_Called_For_SetTime_Expectation(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("TheExampleMethod", 1, 2, 3).Return(5, "6", true).Times(4)
-
- mockedService.TheExampleMethod(1, 2, 3)
- mockedService.TheExampleMethod(1, 2, 3)
- mockedService.TheExampleMethod(1, 2, 3)
- mockedService.TheExampleMethod(1, 2, 3)
- assert.Panics(t, func() {
- mockedService.TheExampleMethod(1, 2, 3)
- })
-
-}
-
-func Test_Mock_Called_Unexpected(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- // make sure it panics if no expectation was made
- assert.Panics(t, func() {
- mockedService.Called(1, 2, 3)
- }, "Calling unexpected method should panic")
-
-}
-
-func Test_AssertExpectationsForObjects_Helper(t *testing.T) {
-
- var mockedService1 = new(TestExampleImplementation)
- var mockedService2 = new(TestExampleImplementation)
- var mockedService3 = new(TestExampleImplementation)
-
- mockedService1.On("Test_AssertExpectationsForObjects_Helper", 1).Return()
- mockedService2.On("Test_AssertExpectationsForObjects_Helper", 2).Return()
- mockedService3.On("Test_AssertExpectationsForObjects_Helper", 3).Return()
-
- mockedService1.Called(1)
- mockedService2.Called(2)
- mockedService3.Called(3)
-
- assert.True(t, AssertExpectationsForObjects(t, mockedService1.Mock, mockedService2.Mock, mockedService3.Mock))
- assert.True(t, AssertExpectationsForObjects(t, mockedService1, mockedService2, mockedService3))
-
-}
-
-func Test_AssertExpectationsForObjects_Helper_Failed(t *testing.T) {
-
- var mockedService1 = new(TestExampleImplementation)
- var mockedService2 = new(TestExampleImplementation)
- var mockedService3 = new(TestExampleImplementation)
-
- mockedService1.On("Test_AssertExpectationsForObjects_Helper_Failed", 1).Return()
- mockedService2.On("Test_AssertExpectationsForObjects_Helper_Failed", 2).Return()
- mockedService3.On("Test_AssertExpectationsForObjects_Helper_Failed", 3).Return()
-
- mockedService1.Called(1)
- mockedService3.Called(3)
-
- tt := new(testing.T)
- assert.False(t, AssertExpectationsForObjects(tt, mockedService1.Mock, mockedService2.Mock, mockedService3.Mock))
- assert.False(t, AssertExpectationsForObjects(tt, mockedService1, mockedService2, mockedService3))
-
-}
-
-func Test_Mock_AssertExpectations(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertExpectations", 1, 2, 3).Return(5, 6, 7)
-
- tt := new(testing.T)
- assert.False(t, mockedService.AssertExpectations(tt))
-
- // make the call now
- mockedService.Called(1, 2, 3)
-
- // now assert expectations
- assert.True(t, mockedService.AssertExpectations(tt))
-
-}
-
-func Test_Mock_AssertExpectations_Placeholder_NoArgs(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertExpectations_Placeholder_NoArgs").Return(5, 6, 7).Once()
- mockedService.On("Test_Mock_AssertExpectations_Placeholder_NoArgs").Return(7, 6, 5)
-
- tt := new(testing.T)
- assert.False(t, mockedService.AssertExpectations(tt))
-
- // make the call now
- mockedService.Called()
-
- // now assert expectations
- assert.True(t, mockedService.AssertExpectations(tt))
-
-}
-
-func Test_Mock_AssertExpectations_Placeholder(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertExpectations_Placeholder", 1, 2, 3).Return(5, 6, 7).Once()
- mockedService.On("Test_Mock_AssertExpectations_Placeholder", 3, 2, 1).Return(7, 6, 5)
-
- tt := new(testing.T)
- assert.False(t, mockedService.AssertExpectations(tt))
-
- // make the call now
- mockedService.Called(1, 2, 3)
-
- // now assert expectations
- assert.False(t, mockedService.AssertExpectations(tt))
-
- // make call to the second expectation
- mockedService.Called(3, 2, 1)
-
- // now assert expectations again
- assert.True(t, mockedService.AssertExpectations(tt))
-}
-
-func Test_Mock_AssertExpectations_With_Pointers(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertExpectations_With_Pointers", &struct{ Foo int }{1}).Return(1)
- mockedService.On("Test_Mock_AssertExpectations_With_Pointers", &struct{ Foo int }{2}).Return(2)
-
- tt := new(testing.T)
- assert.False(t, mockedService.AssertExpectations(tt))
-
- s := struct{ Foo int }{1}
- // make the calls now
- mockedService.Called(&s)
- s.Foo = 2
- mockedService.Called(&s)
-
- // now assert expectations
- assert.True(t, mockedService.AssertExpectations(tt))
-
-}
-
-func Test_Mock_AssertExpectationsCustomType(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).Return(nil).Once()
-
- tt := new(testing.T)
- assert.False(t, mockedService.AssertExpectations(tt))
-
- // make the call now
- mockedService.TheExampleMethod3(&ExampleType{})
-
- // now assert expectations
- assert.True(t, mockedService.AssertExpectations(tt))
-
-}
-
-func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertExpectations_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Twice()
-
- tt := new(testing.T)
- assert.False(t, mockedService.AssertExpectations(tt))
-
- // make the call now
- mockedService.Called(1, 2, 3)
-
- assert.False(t, mockedService.AssertExpectations(tt))
-
- mockedService.Called(1, 2, 3)
-
- // now assert expectations
- assert.True(t, mockedService.AssertExpectations(tt))
-
-}
-
-func Test_Mock_TwoCallsWithDifferentArguments(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_TwoCallsWithDifferentArguments", 1, 2, 3).Return(5, 6, 7)
- mockedService.On("Test_Mock_TwoCallsWithDifferentArguments", 4, 5, 6).Return(5, 6, 7)
-
- args1 := mockedService.Called(1, 2, 3)
- assert.Equal(t, 5, args1.Int(0))
- assert.Equal(t, 6, args1.Int(1))
- assert.Equal(t, 7, args1.Int(2))
-
- args2 := mockedService.Called(4, 5, 6)
- assert.Equal(t, 5, args2.Int(0))
- assert.Equal(t, 6, args2.Int(1))
- assert.Equal(t, 7, args2.Int(2))
-
-}
-
-func Test_Mock_AssertNumberOfCalls(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertNumberOfCalls", 1, 2, 3).Return(5, 6, 7)
-
- mockedService.Called(1, 2, 3)
- assert.True(t, mockedService.AssertNumberOfCalls(t, "Test_Mock_AssertNumberOfCalls", 1))
-
- mockedService.Called(1, 2, 3)
- assert.True(t, mockedService.AssertNumberOfCalls(t, "Test_Mock_AssertNumberOfCalls", 2))
-
-}
-
-func Test_Mock_AssertCalled(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertCalled", 1, 2, 3).Return(5, 6, 7)
-
- mockedService.Called(1, 2, 3)
-
- assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled", 1, 2, 3))
-
-}
-
-func Test_Mock_AssertCalled_WithAnythingOfTypeArgument(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.
- On("Test_Mock_AssertCalled_WithAnythingOfTypeArgument", Anything, Anything, Anything).
- Return()
-
- mockedService.Called(1, "two", []uint8("three"))
-
- assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled_WithAnythingOfTypeArgument", AnythingOfType("int"), AnythingOfType("string"), AnythingOfType("[]uint8")))
-
-}
-
-func Test_Mock_AssertCalled_WithArguments(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertCalled_WithArguments", 1, 2, 3).Return(5, 6, 7)
-
- mockedService.Called(1, 2, 3)
-
- tt := new(testing.T)
- assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 1, 2, 3))
- assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 2, 3, 4))
-
-}
-
-func Test_Mock_AssertCalled_WithArguments_With_Repeatability(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Once()
- mockedService.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4).Return(5, 6, 7).Once()
-
- mockedService.Called(1, 2, 3)
- mockedService.Called(2, 3, 4)
-
- tt := new(testing.T)
- assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3))
- assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4))
- assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 3, 4, 5))
-
-}
-
-func Test_Mock_AssertNotCalled(t *testing.T) {
-
- var mockedService = new(TestExampleImplementation)
-
- mockedService.On("Test_Mock_AssertNotCalled", 1, 2, 3).Return(5, 6, 7)
-
- mockedService.Called(1, 2, 3)
-
- assert.True(t, mockedService.AssertNotCalled(t, "Test_Mock_NotCalled"))
-
-}
-
-/*
- Arguments helper methods
-*/
-func Test_Arguments_Get(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
-
- assert.Equal(t, "string", args.Get(0).(string))
- assert.Equal(t, 123, args.Get(1).(int))
- assert.Equal(t, true, args.Get(2).(bool))
-
-}
-
-func Test_Arguments_Is(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
-
- assert.True(t, args.Is("string", 123, true))
- assert.False(t, args.Is("wrong", 456, false))
-
-}
-
-func Test_Arguments_Diff(t *testing.T) {
-
- var args = Arguments([]interface{}{"Hello World", 123, true})
- var diff string
- var count int
- diff, count = args.Diff([]interface{}{"Hello World", 456, "false"})
-
- assert.Equal(t, 2, count)
- assert.Contains(t, diff, `%!s(int=456) != %!s(int=123)`)
- assert.Contains(t, diff, `false != %!s(bool=true)`)
-
-}
-
-func Test_Arguments_Diff_DifferentNumberOfArgs(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
- var diff string
- var count int
- diff, count = args.Diff([]interface{}{"string", 456, "false", "extra"})
-
- assert.Equal(t, 3, count)
- assert.Contains(t, diff, `extra != (Missing)`)
-
-}
-
-func Test_Arguments_Diff_WithAnythingArgument(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
- var count int
- _, count = args.Diff([]interface{}{"string", Anything, true})
-
- assert.Equal(t, 0, count)
-
-}
-
-func Test_Arguments_Diff_WithAnythingArgument_InActualToo(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", Anything, true})
- var count int
- _, count = args.Diff([]interface{}{"string", 123, true})
-
- assert.Equal(t, 0, count)
-
-}
-
-func Test_Arguments_Diff_WithAnythingOfTypeArgument(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", AnythingOfType("int"), true})
- var count int
- _, count = args.Diff([]interface{}{"string", 123, true})
-
- assert.Equal(t, 0, count)
-
-}
-
-func Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", AnythingOfType("string"), true})
- var count int
- var diff string
- diff, count = args.Diff([]interface{}{"string", 123, true})
-
- assert.Equal(t, 1, count)
- assert.Contains(t, diff, `string != type int - %!s(int=123)`)
-
-}
-
-func Test_Arguments_Diff_WithArgMatcher(t *testing.T) {
- matchFn := func(a int) bool {
- return a == 123
- }
- var args = Arguments([]interface{}{"string", MatchedBy(matchFn), true})
-
- diff, count := args.Diff([]interface{}{"string", 124, true})
- assert.Equal(t, 1, count)
- assert.Contains(t, diff, `%!s(int=124) not matched by func(int) bool`)
-
- diff, count = args.Diff([]interface{}{"string", false, true})
- assert.Equal(t, 1, count)
- assert.Contains(t, diff, `%!s(bool=false) not matched by func(int) bool`)
-
- diff, count = args.Diff([]interface{}{"string", 123, false})
- assert.Contains(t, diff, `%!s(int=123) matched by func(int) bool`)
-
- diff, count = args.Diff([]interface{}{"string", 123, true})
- assert.Equal(t, 0, count)
- assert.Contains(t, diff, `No differences.`)
-}
-
-func Test_Arguments_Assert(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
-
- assert.True(t, args.Assert(t, "string", 123, true))
-
-}
-
-func Test_Arguments_String_Representation(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
- assert.Equal(t, `string,int,bool`, args.String())
-
-}
-
-func Test_Arguments_String(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
- assert.Equal(t, "string", args.String(0))
-
-}
-
-func Test_Arguments_Error(t *testing.T) {
-
- var err = errors.New("An Error")
- var args = Arguments([]interface{}{"string", 123, true, err})
- assert.Equal(t, err, args.Error(3))
-
-}
-
-func Test_Arguments_Error_Nil(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true, nil})
- assert.Equal(t, nil, args.Error(3))
-
-}
-
-func Test_Arguments_Int(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
- assert.Equal(t, 123, args.Int(1))
-
-}
-
-func Test_Arguments_Bool(t *testing.T) {
-
- var args = Arguments([]interface{}{"string", 123, true})
- assert.Equal(t, true, args.Bool(2))
-
-}
diff --git a/vendor/github.com/stretchr/testify/require/doc.go b/vendor/github.com/stretchr/testify/require/doc.go
deleted file mode 100644
index 169de392..00000000
--- a/vendor/github.com/stretchr/testify/require/doc.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Package require implements the same assertions as the `assert` package but
-// stops test execution when a test fails.
-//
-// Example Usage
-//
-// The following is a complete example using require in a standard test function:
-// import (
-// "testing"
-// "github.com/stretchr/testify/require"
-// )
-//
-// func TestSomething(t *testing.T) {
-//
-// var a string = "Hello"
-// var b string = "Hello"
-//
-// require.Equal(t, a, b, "The two words should be the same.")
-//
-// }
-//
-// Assertions
-//
-// The `require` package have same global functions as in the `assert` package,
-// but instead of returning a boolean result they call `t.FailNow()`.
-//
-// Every assertion function also takes an optional string message as the final argument,
-// allowing custom error messages to be appended to the message the assertion method outputs.
-package require
diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements.go b/vendor/github.com/stretchr/testify/require/forward_requirements.go
deleted file mode 100644
index d3c2ab9b..00000000
--- a/vendor/github.com/stretchr/testify/require/forward_requirements.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package require
-
-// Assertions provides assertion methods around the
-// TestingT interface.
-type Assertions struct {
- t TestingT
-}
-
-// New makes a new Assertions object for the specified TestingT.
-func New(t TestingT) *Assertions {
- return &Assertions{
- t: t,
- }
-}
-
-//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl
diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements_test.go b/vendor/github.com/stretchr/testify/require/forward_requirements_test.go
deleted file mode 100644
index b120ae3b..00000000
--- a/vendor/github.com/stretchr/testify/require/forward_requirements_test.go
+++ /dev/null
@@ -1,385 +0,0 @@
-package require
-
-import (
- "errors"
- "testing"
- "time"
-)
-
-func TestImplementsWrapper(t *testing.T) {
- require := New(t)
-
- require.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject))
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestIsTypeWrapper(t *testing.T) {
- require := New(t)
- require.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject))
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestEqualWrapper(t *testing.T) {
- require := New(t)
- require.Equal(1, 1)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Equal(1, 2)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotEqualWrapper(t *testing.T) {
- require := New(t)
- require.NotEqual(1, 2)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.NotEqual(2, 2)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestExactlyWrapper(t *testing.T) {
- require := New(t)
-
- a := float32(1)
- b := float32(1)
- c := float64(1)
-
- require.Exactly(a, b)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Exactly(a, c)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotNilWrapper(t *testing.T) {
- require := New(t)
- require.NotNil(t, new(AssertionTesterConformingObject))
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.NotNil(nil)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNilWrapper(t *testing.T) {
- require := New(t)
- require.Nil(nil)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Nil(new(AssertionTesterConformingObject))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestTrueWrapper(t *testing.T) {
- require := New(t)
- require.True(true)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.True(false)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestFalseWrapper(t *testing.T) {
- require := New(t)
- require.False(false)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.False(true)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestContainsWrapper(t *testing.T) {
- require := New(t)
- require.Contains("Hello World", "Hello")
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Contains("Hello World", "Salut")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotContainsWrapper(t *testing.T) {
- require := New(t)
- require.NotContains("Hello World", "Hello!")
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.NotContains("Hello World", "Hello")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestPanicsWrapper(t *testing.T) {
- require := New(t)
- require.Panics(func() {
- panic("Panic!")
- })
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Panics(func() {})
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotPanicsWrapper(t *testing.T) {
- require := New(t)
- require.NotPanics(func() {})
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.NotPanics(func() {
- panic("Panic!")
- })
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNoErrorWrapper(t *testing.T) {
- require := New(t)
- require.NoError(nil)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.NoError(errors.New("some error"))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestErrorWrapper(t *testing.T) {
- require := New(t)
- require.Error(errors.New("some error"))
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Error(nil)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestEqualErrorWrapper(t *testing.T) {
- require := New(t)
- require.EqualError(errors.New("some error"), "some error")
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.EqualError(errors.New("some error"), "Not some error")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestEmptyWrapper(t *testing.T) {
- require := New(t)
- require.Empty("")
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Empty("x")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotEmptyWrapper(t *testing.T) {
- require := New(t)
- require.NotEmpty("x")
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.NotEmpty("")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestWithinDurationWrapper(t *testing.T) {
- require := New(t)
- a := time.Now()
- b := a.Add(10 * time.Second)
-
- require.WithinDuration(a, b, 15*time.Second)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.WithinDuration(a, b, 5*time.Second)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestInDeltaWrapper(t *testing.T) {
- require := New(t)
- require.InDelta(1.001, 1, 0.01)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.InDelta(1, 2, 0.5)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestZeroWrapper(t *testing.T) {
- require := New(t)
- require.Zero(0)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.Zero(1)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotZeroWrapper(t *testing.T) {
- require := New(t)
- require.NotZero(1)
-
- mockT := new(MockT)
- mockRequire := New(mockT)
- mockRequire.NotZero(0)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEqWrapper_EqualSONString(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`)
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq("{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}",
- "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}")
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEqWrapper_Array(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`)
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq(`{"foo": "bar"}`, "Not JSON")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq("Not JSON", `{"foo": "bar", "hello": "world"}`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq("Not JSON", "Not JSON")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
- mockT := new(MockT)
- mockRequire := New(mockT)
-
- mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go
deleted file mode 100644
index 1bcfcb0d..00000000
--- a/vendor/github.com/stretchr/testify/require/require.go
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
-*/
-
-package require
-
-import (
-
- assert "github.com/stretchr/testify/assert"
- http "net/http"
- url "net/url"
- time "time"
-)
-
-
-// Condition uses a Comparison to assert a complex condition.
-func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
- if !assert.Condition(t, comp, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Contains asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'")
-// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
-// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- if !assert.Contains(t, s, contains, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// assert.Empty(t, obj)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if !assert.Empty(t, object, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Equal asserts that two objects are equal.
-//
-// assert.Equal(t, 123, 123, "123 and 123 should be equal")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if !assert.Equal(t, expected, actual, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// EqualError asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// if assert.Error(t, err, "An error was expected") {
-// assert.Equal(t, err, expectedError)
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
- if !assert.EqualError(t, theError, errString, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// EqualValues asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if !assert.EqualValues(t, expected, actual, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Error asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.Error(t, err, "An error was expected") {
-// assert.Equal(t, err, expectedError)
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Error(t TestingT, err error, msgAndArgs ...interface{}) {
- if !assert.Error(t, err, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// 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")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if !assert.Exactly(t, expected, actual, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Fail reports a failure through
-func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
- if !assert.Fail(t, failureMessage, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// FailNow fails test
-func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
- if !assert.FailNow(t, failureMessage, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// False asserts that the specified value is false.
-//
-// assert.False(t, myBool, "myBool should be false")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func False(t TestingT, value bool, msgAndArgs ...interface{}) {
- if !assert.False(t, value, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// HTTPBodyContains asserts that a specified handler returns a
-// body that contains a string.
-//
-// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
- if !assert.HTTPBodyContains(t, handler, method, url, values, str) {
- t.FailNow()
- }
-}
-
-
-// HTTPBodyNotContains asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
- if !assert.HTTPBodyNotContains(t, handler, method, url, values, str) {
- t.FailNow()
- }
-}
-
-
-// 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"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
- if !assert.HTTPError(t, handler, method, url, values) {
- t.FailNow()
- }
-}
-
-
-// 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"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
- if !assert.HTTPRedirect(t, handler, method, url, values) {
- t.FailNow()
- }
-}
-
-
-// HTTPSuccess asserts that a specified handler returns a success status code.
-//
-// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
- if !assert.HTTPSuccess(t, handler, method, url, values) {
- t.FailNow()
- }
-}
-
-
-// Implements asserts that an object is implemented by the specified interface.
-//
-// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject")
-func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
- if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// InDelta asserts that the two numerals are within delta of each other.
-//
-// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if !assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// InDeltaSlice is the same as InDelta, except it compares two slices.
-func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if !assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// InEpsilon asserts that expected and actual have a relative error less than epsilon
-//
-// Returns whether the assertion was successful (true) or not (false).
-func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
- if !assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// InEpsilonSlice is the same as InEpsilon, except it compares two slices.
-func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- if !assert.InEpsilonSlice(t, expected, actual, delta, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// IsType asserts that the specified objects are of the same type.
-func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
- if !assert.IsType(t, expectedType, object, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// JSONEq asserts that two JSON strings are equivalent.
-//
-// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
- if !assert.JSONEq(t, expected, actual, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Len asserts that the specified object has specific length.
-// 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")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
- if !assert.Len(t, object, length, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Nil asserts that the specified object is nil.
-//
-// assert.Nil(t, err, "err should be nothing")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if !assert.Nil(t, object, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// NoError asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if assert.NoError(t, err) {
-// assert.Equal(t, actualObj, expectedObj)
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
- if !assert.NoError(t, err, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
-// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
-// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- if !assert.NotContains(t, s, contains, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// 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.
-//
-// if assert.NotEmpty(t, obj) {
-// assert.Equal(t, "two", obj[1])
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if !assert.NotEmpty(t, object, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// NotEqual asserts that the specified values are NOT equal.
-//
-// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- if !assert.NotEqual(t, expected, actual, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// NotNil asserts that the specified object is not nil.
-//
-// assert.NotNil(t, err, "err should be something")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
- if !assert.NotNil(t, object, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// assert.NotPanics(t, func(){
-// RemainCalm()
-// }, "Calling RemainCalm() should NOT panic")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if !assert.NotPanics(t, f, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// NotRegexp asserts that a specified regexp does not match a string.
-//
-// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
-// assert.NotRegexp(t, "^start", "it's not starting")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- if !assert.NotRegexp(t, rx, str, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// NotZero asserts that i is not the zero value for its type and returns the truth.
-func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
- if !assert.NotZero(t, i, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Panics asserts that the code inside the specified PanicTestFunc panics.
-//
-// assert.Panics(t, func(){
-// GoCrazy()
-// }, "Calling GoCrazy() should panic")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- if !assert.Panics(t, f, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Regexp asserts that a specified regexp matches a string.
-//
-// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
-// assert.Regexp(t, "start...$", "it's not starting")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- if !assert.Regexp(t, rx, str, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// True asserts that the specified value is true.
-//
-// assert.True(t, myBool, "myBool should be true")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func True(t TestingT, value bool, msgAndArgs ...interface{}) {
- if !assert.True(t, value, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// 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")
-//
-// 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{}) {
- if !assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
- t.FailNow()
- }
-}
-
-
-// Zero asserts that i is the zero value for its type and returns the truth.
-func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
- if !assert.Zero(t, i, msgAndArgs...) {
- t.FailNow()
- }
-}
diff --git a/vendor/github.com/stretchr/testify/require/require.go.tmpl b/vendor/github.com/stretchr/testify/require/require.go.tmpl
deleted file mode 100644
index ab1b1e9f..00000000
--- a/vendor/github.com/stretchr/testify/require/require.go.tmpl
+++ /dev/null
@@ -1,6 +0,0 @@
-{{.Comment}}
-func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
- if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) {
- t.FailNow()
- }
-}
diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go
deleted file mode 100644
index 58324f10..00000000
--- a/vendor/github.com/stretchr/testify/require/require_forward.go
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
-* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
-* THIS FILE MUST NOT BE EDITED BY HAND
-*/
-
-package require
-
-import (
-
- assert "github.com/stretchr/testify/assert"
- http "net/http"
- url "net/url"
- time "time"
-)
-
-
-// Condition uses a Comparison to assert a complex condition.
-func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) {
- Condition(a.t, comp, msgAndArgs...)
-}
-
-
-// Contains asserts that the specified string, list(array, slice...) or map contains the
-// specified substring or element.
-//
-// a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'")
-// a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'")
-// a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- Contains(a.t, s, contains, msgAndArgs...)
-}
-
-
-// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
-// a slice or a channel with len == 0.
-//
-// a.Empty(obj)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
- Empty(a.t, object, msgAndArgs...)
-}
-
-
-// Equal asserts that two objects are equal.
-//
-// a.Equal(123, 123, "123 and 123 should be equal")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- Equal(a.t, expected, actual, msgAndArgs...)
-}
-
-
-// EqualError asserts that a function returned an error (i.e. not `nil`)
-// and that it is equal to the provided error.
-//
-// actualObj, err := SomeFunction()
-// if assert.Error(t, err, "An error was expected") {
-// assert.Equal(t, err, expectedError)
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
- EqualError(a.t, theError, errString, msgAndArgs...)
-}
-
-
-// EqualValues asserts that two objects are equal or convertable to the same types
-// and equal.
-//
-// a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- EqualValues(a.t, expected, actual, msgAndArgs...)
-}
-
-
-// Error asserts that a function returned an error (i.e. not `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.Error(err, "An error was expected") {
-// assert.Equal(t, err, expectedError)
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
- Error(a.t, err, msgAndArgs...)
-}
-
-
-// Exactly asserts that two objects are equal is value and type.
-//
-// a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- Exactly(a.t, expected, actual, msgAndArgs...)
-}
-
-
-// Fail reports a failure through
-func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
- Fail(a.t, failureMessage, msgAndArgs...)
-}
-
-
-// FailNow fails test
-func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
- FailNow(a.t, failureMessage, msgAndArgs...)
-}
-
-
-// False asserts that the specified value is false.
-//
-// a.False(myBool, "myBool should be false")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
- False(a.t, value, msgAndArgs...)
-}
-
-
-// HTTPBodyContains asserts that a specified handler returns a
-// body that contains a string.
-//
-// a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
- HTTPBodyContains(a.t, handler, method, url, values, str)
-}
-
-
-// HTTPBodyNotContains asserts that a specified handler returns a
-// body that does not contain a string.
-//
-// a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
- HTTPBodyNotContains(a.t, handler, method, url, values, str)
-}
-
-
-// HTTPError asserts that a specified handler returns an error status code.
-//
-// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) {
- HTTPError(a.t, handler, method, url, values)
-}
-
-
-// HTTPRedirect asserts that a specified handler returns a redirect status code.
-//
-// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) {
- HTTPRedirect(a.t, handler, method, url, values)
-}
-
-
-// HTTPSuccess asserts that a specified handler returns a success status code.
-//
-// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) {
- HTTPSuccess(a.t, handler, method, url, values)
-}
-
-
-// Implements asserts that an object is implemented by the specified interface.
-//
-// a.Implements((*MyInterface)(nil), new(MyObject), "MyObject")
-func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
- Implements(a.t, interfaceObject, object, msgAndArgs...)
-}
-
-
-// InDelta asserts that the two numerals are within delta of each other.
-//
-// a.InDelta(math.Pi, (22 / 7.0), 0.01)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- InDelta(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-
-// InDeltaSlice is the same as InDelta, except it compares two slices.
-func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-
-// InEpsilon 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) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
- InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
-}
-
-
-// InEpsilonSlice is the same as InEpsilon, except it compares two slices.
-func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
- InEpsilonSlice(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-
-// IsType asserts that the specified objects are of the same type.
-func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
- IsType(a.t, expectedType, object, msgAndArgs...)
-}
-
-
-// JSONEq asserts that two JSON strings are equivalent.
-//
-// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
- JSONEq(a.t, expected, actual, msgAndArgs...)
-}
-
-
-// Len asserts that the specified object has specific length.
-// Len also fails if the object has a type that len() not accept.
-//
-// a.Len(mySlice, 3, "The size of slice is not 3")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
- Len(a.t, object, length, msgAndArgs...)
-}
-
-
-// Nil asserts that the specified object is nil.
-//
-// a.Nil(err, "err should be nothing")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
- Nil(a.t, object, msgAndArgs...)
-}
-
-
-// NoError asserts that a function returned no error (i.e. `nil`).
-//
-// actualObj, err := SomeFunction()
-// if a.NoError(err) {
-// assert.Equal(t, actualObj, expectedObj)
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
- NoError(a.t, err, msgAndArgs...)
-}
-
-
-// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
-// specified substring or element.
-//
-// a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'")
-// a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'")
-// a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
- NotContains(a.t, s, contains, msgAndArgs...)
-}
-
-
-// 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.
-//
-// if a.NotEmpty(obj) {
-// assert.Equal(t, "two", obj[1])
-// }
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
- NotEmpty(a.t, object, msgAndArgs...)
-}
-
-
-// NotEqual asserts that the specified values are NOT equal.
-//
-// a.NotEqual(obj1, obj2, "two objects shouldn't be equal")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
- NotEqual(a.t, expected, actual, msgAndArgs...)
-}
-
-
-// NotNil asserts that the specified object is not nil.
-//
-// a.NotNil(err, "err should be something")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
- NotNil(a.t, object, msgAndArgs...)
-}
-
-
-// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
-//
-// a.NotPanics(func(){
-// RemainCalm()
-// }, "Calling RemainCalm() should NOT panic")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- NotPanics(a.t, f, msgAndArgs...)
-}
-
-
-// NotRegexp asserts that a specified regexp does not match a string.
-//
-// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
-// a.NotRegexp("^start", "it's not starting")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- NotRegexp(a.t, rx, str, msgAndArgs...)
-}
-
-
-// NotZero asserts that i is not the zero value for its type and returns the truth.
-func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
- NotZero(a.t, i, msgAndArgs...)
-}
-
-
-// Panics asserts that the code inside the specified PanicTestFunc panics.
-//
-// a.Panics(func(){
-// GoCrazy()
-// }, "Calling GoCrazy() should panic")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
- Panics(a.t, f, msgAndArgs...)
-}
-
-
-// Regexp asserts that a specified regexp matches a string.
-//
-// a.Regexp(regexp.MustCompile("start"), "it's starting")
-// a.Regexp("start...$", "it's not starting")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
- Regexp(a.t, rx, str, msgAndArgs...)
-}
-
-
-// True asserts that the specified value is true.
-//
-// a.True(myBool, "myBool should be true")
-//
-// Returns whether the assertion was successful (true) or not (false).
-func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
- True(a.t, value, msgAndArgs...)
-}
-
-
-// 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")
-//
-// 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{}) {
- WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
-}
-
-
-// Zero asserts that i is the zero value for its type and returns the truth.
-func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
- Zero(a.t, i, msgAndArgs...)
-}
diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl b/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
deleted file mode 100644
index b93569e0..00000000
--- a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
+++ /dev/null
@@ -1,4 +0,0 @@
-{{.CommentWithoutT "a"}}
-func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {
- {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
-}
diff --git a/vendor/github.com/stretchr/testify/require/requirements.go b/vendor/github.com/stretchr/testify/require/requirements.go
deleted file mode 100644
index 41147562..00000000
--- a/vendor/github.com/stretchr/testify/require/requirements.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package require
-
-// TestingT is an interface wrapper around *testing.T
-type TestingT interface {
- Errorf(format string, args ...interface{})
- FailNow()
-}
-
-//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl
diff --git a/vendor/github.com/stretchr/testify/require/requirements_test.go b/vendor/github.com/stretchr/testify/require/requirements_test.go
deleted file mode 100644
index d2ccc99c..00000000
--- a/vendor/github.com/stretchr/testify/require/requirements_test.go
+++ /dev/null
@@ -1,369 +0,0 @@
-package require
-
-import (
- "errors"
- "testing"
- "time"
-)
-
-// AssertionTesterInterface defines an interface to be used for testing assertion methods
-type AssertionTesterInterface interface {
- TestMethod()
-}
-
-// AssertionTesterConformingObject is an object that conforms to the AssertionTesterInterface interface
-type AssertionTesterConformingObject struct {
-}
-
-func (a *AssertionTesterConformingObject) TestMethod() {
-}
-
-// AssertionTesterNonConformingObject is an object that does not conform to the AssertionTesterInterface interface
-type AssertionTesterNonConformingObject struct {
-}
-
-type MockT struct {
- Failed bool
-}
-
-func (t *MockT) FailNow() {
- t.Failed = true
-}
-
-func (t *MockT) Errorf(format string, args ...interface{}) {
- _, _ = format, args
-}
-
-func TestImplements(t *testing.T) {
-
- Implements(t, (*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject))
-
- mockT := new(MockT)
- Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestIsType(t *testing.T) {
-
- IsType(t, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject))
-
- mockT := new(MockT)
- IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestEqual(t *testing.T) {
-
- Equal(t, 1, 1)
-
- mockT := new(MockT)
- Equal(mockT, 1, 2)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-
-}
-
-func TestNotEqual(t *testing.T) {
-
- NotEqual(t, 1, 2)
- mockT := new(MockT)
- NotEqual(mockT, 2, 2)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestExactly(t *testing.T) {
-
- a := float32(1)
- b := float32(1)
- c := float64(1)
-
- Exactly(t, a, b)
-
- mockT := new(MockT)
- Exactly(mockT, a, c)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotNil(t *testing.T) {
-
- NotNil(t, new(AssertionTesterConformingObject))
-
- mockT := new(MockT)
- NotNil(mockT, nil)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNil(t *testing.T) {
-
- Nil(t, nil)
-
- mockT := new(MockT)
- Nil(mockT, new(AssertionTesterConformingObject))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestTrue(t *testing.T) {
-
- True(t, true)
-
- mockT := new(MockT)
- True(mockT, false)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestFalse(t *testing.T) {
-
- False(t, false)
-
- mockT := new(MockT)
- False(mockT, true)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestContains(t *testing.T) {
-
- Contains(t, "Hello World", "Hello")
-
- mockT := new(MockT)
- Contains(mockT, "Hello World", "Salut")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotContains(t *testing.T) {
-
- NotContains(t, "Hello World", "Hello!")
-
- mockT := new(MockT)
- NotContains(mockT, "Hello World", "Hello")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestPanics(t *testing.T) {
-
- Panics(t, func() {
- panic("Panic!")
- })
-
- mockT := new(MockT)
- Panics(mockT, func() {})
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotPanics(t *testing.T) {
-
- NotPanics(t, func() {})
-
- mockT := new(MockT)
- NotPanics(mockT, func() {
- panic("Panic!")
- })
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNoError(t *testing.T) {
-
- NoError(t, nil)
-
- mockT := new(MockT)
- NoError(mockT, errors.New("some error"))
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestError(t *testing.T) {
-
- Error(t, errors.New("some error"))
-
- mockT := new(MockT)
- Error(mockT, nil)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestEqualError(t *testing.T) {
-
- EqualError(t, errors.New("some error"), "some error")
-
- mockT := new(MockT)
- EqualError(mockT, errors.New("some error"), "Not some error")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestEmpty(t *testing.T) {
-
- Empty(t, "")
-
- mockT := new(MockT)
- Empty(mockT, "x")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotEmpty(t *testing.T) {
-
- NotEmpty(t, "x")
-
- mockT := new(MockT)
- NotEmpty(mockT, "")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestWithinDuration(t *testing.T) {
-
- a := time.Now()
- b := a.Add(10 * time.Second)
-
- WithinDuration(t, a, b, 15*time.Second)
-
- mockT := new(MockT)
- WithinDuration(mockT, a, b, 5*time.Second)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestInDelta(t *testing.T) {
-
- InDelta(t, 1.001, 1, 0.01)
-
- mockT := new(MockT)
- InDelta(mockT, 1, 2, 0.5)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestZero(t *testing.T) {
-
- Zero(t, "")
-
- mockT := new(MockT)
- Zero(mockT, "x")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestNotZero(t *testing.T) {
-
- NotZero(t, "x")
-
- mockT := new(MockT)
- NotZero(mockT, "")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEq_EqualSONString(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`)
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEq_EquivalentButNotEqual(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEq_HashOfArraysAndHashes(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, "{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}",
- "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}")
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEq_Array(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`)
- if mockT.Failed {
- t.Error("Check should pass")
- }
-}
-
-func TestJSONEq_HashAndArrayNotEquivalent(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEq_HashesNotEquivalent(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, `{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEq_ActualIsNotJSON(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, `{"foo": "bar"}`, "Not JSON")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEq_ExpectedIsNotJSON(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, "Not JSON", `{"foo": "bar", "hello": "world"}`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEq_ExpectedAndActualNotJSON(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, "Not JSON", "Not JSON")
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
-
-func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) {
- mockT := new(MockT)
- JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`)
- if !mockT.Failed {
- t.Error("Check should fail")
- }
-}
diff --git a/vendor/github.com/stretchr/testify/suite/doc.go b/vendor/github.com/stretchr/testify/suite/doc.go
deleted file mode 100644
index f91a245d..00000000
--- a/vendor/github.com/stretchr/testify/suite/doc.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// Package suite contains logic for creating testing suite structs
-// and running the methods on those structs as tests. The most useful
-// piece of this package is that you can create setup/teardown methods
-// on your testing suites, which will run before/after the whole suite
-// or individual tests (depending on which interface(s) you
-// implement).
-//
-// A testing suite is usually built by first extending the built-in
-// suite functionality from suite.Suite in testify. Alternatively,
-// you could reproduce that logic on your own if you wanted (you
-// just need to implement the TestingSuite interface from
-// suite/interfaces.go).
-//
-// After that, you can implement any of the interfaces in
-// suite/interfaces.go to add setup/teardown functionality to your
-// suite, and add any methods that start with "Test" to add tests.
-// Methods that do not match any suite interfaces and do not begin
-// with "Test" will not be run by testify, and can safely be used as
-// helper methods.
-//
-// Once you've built your testing suite, you need to run the suite
-// (using suite.Run from testify) inside any function that matches the
-// identity that "go test" is already looking for (i.e.
-// func(*testing.T)).
-//
-// Regular expression to select test suites specified command-line
-// argument "-run". Regular expression to select the methods
-// of test suites specified command-line argument "-m".
-// Suite object has assertion methods.
-//
-// A crude example:
-// // Basic imports
-// import (
-// "testing"
-// "github.com/stretchr/testify/assert"
-// "github.com/stretchr/testify/suite"
-// )
-//
-// // Define the suite, and absorb the built-in basic suite
-// // functionality from testify - including a T() method which
-// // returns the current testing context
-// type ExampleTestSuite struct {
-// suite.Suite
-// VariableThatShouldStartAtFive int
-// }
-//
-// // Make sure that VariableThatShouldStartAtFive is set to five
-// // before each test
-// func (suite *ExampleTestSuite) SetupTest() {
-// suite.VariableThatShouldStartAtFive = 5
-// }
-//
-// // All methods that begin with "Test" are run as tests within a
-// // suite.
-// func (suite *ExampleTestSuite) TestExample() {
-// assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive)
-// suite.Equal(5, suite.VariableThatShouldStartAtFive)
-// }
-//
-// // In order for 'go test' to run this suite, we need to create
-// // a normal test function and pass our suite to suite.Run
-// func TestExampleTestSuite(t *testing.T) {
-// suite.Run(t, new(ExampleTestSuite))
-// }
-package suite
diff --git a/vendor/github.com/stretchr/testify/suite/interfaces.go b/vendor/github.com/stretchr/testify/suite/interfaces.go
deleted file mode 100644
index 20969472..00000000
--- a/vendor/github.com/stretchr/testify/suite/interfaces.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package suite
-
-import "testing"
-
-// TestingSuite can store and return the current *testing.T context
-// generated by 'go test'.
-type TestingSuite interface {
- T() *testing.T
- SetT(*testing.T)
-}
-
-// SetupAllSuite has a SetupSuite method, which will run before the
-// tests in the suite are run.
-type SetupAllSuite interface {
- SetupSuite()
-}
-
-// SetupTestSuite has a SetupTest method, which will run before each
-// test in the suite.
-type SetupTestSuite interface {
- SetupTest()
-}
-
-// TearDownAllSuite has a TearDownSuite method, which will run after
-// all the tests in the suite have been run.
-type TearDownAllSuite interface {
- TearDownSuite()
-}
-
-// TearDownTestSuite has a TearDownTest method, which will run after
-// each test in the suite.
-type TearDownTestSuite interface {
- TearDownTest()
-}
diff --git a/vendor/github.com/stretchr/testify/suite/suite.go b/vendor/github.com/stretchr/testify/suite/suite.go
deleted file mode 100644
index db741300..00000000
--- a/vendor/github.com/stretchr/testify/suite/suite.go
+++ /dev/null
@@ -1,115 +0,0 @@
-package suite
-
-import (
- "flag"
- "fmt"
- "os"
- "reflect"
- "regexp"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-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
-// retrieving the current *testing.T context.
-type Suite struct {
- *assert.Assertions
- require *require.Assertions
- t *testing.T
-}
-
-// T retrieves the current *testing.T context.
-func (suite *Suite) T() *testing.T {
- return suite.t
-}
-
-// SetT sets the current *testing.T context.
-func (suite *Suite) SetT(t *testing.T) {
- suite.t = t
- suite.Assertions = assert.New(t)
- suite.require = require.New(t)
-}
-
-// Require returns a require context for suite.
-func (suite *Suite) Require() *require.Assertions {
- if suite.require == nil {
- suite.require = require.New(suite.T())
- }
- return suite.require
-}
-
-// Assert returns an assert context for suite. Normally, you can call
-// `suite.NoError(expected, actual)`, but for situations where the embedded
-// methods are overridden (for example, you might want to override
-// assert.Assertions with require.Assertions), this method is provided so you
-// can call `suite.Assert().NoError()`.
-func (suite *Suite) Assert() *assert.Assertions {
- if suite.Assertions == nil {
- suite.Assertions = assert.New(suite.T())
- }
- return suite.Assertions
-}
-
-// Run takes a testing suite and runs all of the tests attached
-// to it.
-func Run(t *testing.T, suite TestingSuite) {
- suite.SetT(t)
-
- if setupAllSuite, ok := suite.(SetupAllSuite); ok {
- setupAllSuite.SetupSuite()
- }
- defer func() {
- if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok {
- tearDownAllSuite.TearDownSuite()
- }
- }()
-
- methodFinder := reflect.TypeOf(suite)
- tests := []testing.InternalTest{}
- for index := 0; index < methodFinder.NumMethod(); index++ {
- method := methodFinder.Method(index)
- ok, err := methodFilter(method.Name)
- if err != nil {
- fmt.Fprintf(os.Stderr, "testify: invalid regexp for -m: %s\n", err)
- os.Exit(1)
- }
- if ok {
- test := testing.InternalTest{
- Name: method.Name,
- F: func(t *testing.T) {
- parentT := suite.T()
- suite.SetT(t)
- if setupTestSuite, ok := suite.(SetupTestSuite); ok {
- setupTestSuite.SetupTest()
- }
- defer func() {
- if tearDownTestSuite, ok := suite.(TearDownTestSuite); ok {
- tearDownTestSuite.TearDownTest()
- }
- suite.SetT(parentT)
- }()
- method.Func.Call([]reflect.Value{reflect.ValueOf(suite)})
- },
- }
- tests = append(tests, test)
- }
- }
-
- if !testing.RunTests(func(_, _ string) (bool, error) { return true, nil },
- tests) {
- t.Fail()
- }
-}
-
-// Filtering method according to set regular expression
-// specified command-line argument -m
-func methodFilter(name string) (bool, error) {
- if ok, _ := regexp.MatchString("^Test", name); !ok {
- return false, nil
- }
- return regexp.MatchString(*matchMethod, name)
-}
diff --git a/vendor/github.com/stretchr/testify/suite/suite_test.go b/vendor/github.com/stretchr/testify/suite/suite_test.go
deleted file mode 100644
index c7c4e88f..00000000
--- a/vendor/github.com/stretchr/testify/suite/suite_test.go
+++ /dev/null
@@ -1,239 +0,0 @@
-package suite
-
-import (
- "errors"
- "io/ioutil"
- "os"
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-// SuiteRequireTwice is intended to test the usage of suite.Require in two
-// different tests
-type SuiteRequireTwice struct{ Suite }
-
-// TestSuiteRequireTwice checks for regressions of issue #149 where
-// suite.requirements was not initialised in suite.SetT()
-// A regression would result on these tests panicking rather than failing.
-func TestSuiteRequireTwice(t *testing.T) {
- ok := testing.RunTests(
- func(_, _ string) (bool, error) { return true, nil },
- []testing.InternalTest{{
- Name: "TestSuiteRequireTwice",
- F: func(t *testing.T) {
- suite := new(SuiteRequireTwice)
- Run(t, suite)
- },
- }},
- )
- assert.Equal(t, false, ok)
-}
-
-func (s *SuiteRequireTwice) TestRequireOne() {
- r := s.Require()
- r.Equal(1, 2)
-}
-
-func (s *SuiteRequireTwice) TestRequireTwo() {
- r := s.Require()
- r.Equal(1, 2)
-}
-
-// This suite is intended to store values to make sure that only
-// testing-suite-related methods are run. It's also a fully
-// functional example of a testing suite, using setup/teardown methods
-// and a helper method that is ignored by testify. To make this look
-// more like a real world example, all tests in the suite perform some
-// type of assertion.
-type SuiteTester struct {
- // Include our basic suite logic.
- Suite
-
- // Keep counts of how many times each method is run.
- SetupSuiteRunCount int
- TearDownSuiteRunCount int
- SetupTestRunCount int
- TearDownTestRunCount int
- TestOneRunCount int
- TestTwoRunCount int
- NonTestMethodRunCount int
-}
-
-type SuiteSkipTester struct {
- // Include our basic suite logic.
- Suite
-
- // Keep counts of how many times each method is run.
- SetupSuiteRunCount int
- TearDownSuiteRunCount int
-}
-
-// The SetupSuite method will be run by testify once, at the very
-// start of the testing suite, before any tests are run.
-func (suite *SuiteTester) SetupSuite() {
- suite.SetupSuiteRunCount++
-}
-
-func (suite *SuiteSkipTester) SetupSuite() {
- suite.SetupSuiteRunCount++
- suite.T().Skip()
-}
-
-// The TearDownSuite method will be run by testify once, at the very
-// end of the testing suite, after all tests have been run.
-func (suite *SuiteTester) TearDownSuite() {
- suite.TearDownSuiteRunCount++
-}
-
-func (suite *SuiteSkipTester) TearDownSuite() {
- suite.TearDownSuiteRunCount++
-}
-
-// The SetupTest method will be run before every test in the suite.
-func (suite *SuiteTester) SetupTest() {
- suite.SetupTestRunCount++
-}
-
-// The TearDownTest method will be run after every test in the suite.
-func (suite *SuiteTester) TearDownTest() {
- suite.TearDownTestRunCount++
-}
-
-// Every method in a testing suite that begins with "Test" will be run
-// as a test. TestOne is an example of a test. For the purposes of
-// this example, we've included assertions in the tests, since most
-// tests will issue assertions.
-func (suite *SuiteTester) TestOne() {
- beforeCount := suite.TestOneRunCount
- suite.TestOneRunCount++
- assert.Equal(suite.T(), suite.TestOneRunCount, beforeCount+1)
- suite.Equal(suite.TestOneRunCount, beforeCount+1)
-}
-
-// TestTwo is another example of a test.
-func (suite *SuiteTester) TestTwo() {
- beforeCount := suite.TestTwoRunCount
- suite.TestTwoRunCount++
- assert.NotEqual(suite.T(), suite.TestTwoRunCount, beforeCount)
- suite.NotEqual(suite.TestTwoRunCount, beforeCount)
-}
-
-func (suite *SuiteTester) TestSkip() {
- suite.T().Skip()
-}
-
-// NonTestMethod does not begin with "Test", so it will not be run by
-// testify as a test in the suite. This is useful for creating helper
-// methods for your tests.
-func (suite *SuiteTester) NonTestMethod() {
- suite.NonTestMethodRunCount++
-}
-
-// TestRunSuite will be run by the 'go test' command, so within it, we
-// can run our suite using the Run(*testing.T, TestingSuite) function.
-func TestRunSuite(t *testing.T) {
- suiteTester := new(SuiteTester)
- Run(t, suiteTester)
-
- // Normally, the test would end here. The following are simply
- // some assertions to ensure that the Run function is working as
- // intended - they are not part of the example.
-
- // The suite was only run once, so the SetupSuite and TearDownSuite
- // methods should have each been run only once.
- assert.Equal(t, suiteTester.SetupSuiteRunCount, 1)
- assert.Equal(t, suiteTester.TearDownSuiteRunCount, 1)
-
- // There are three test methods (TestOne, TestTwo, and TestSkip), so
- // the SetupTest and TearDownTest methods (which should be run once for
- // each test) should have been run three times.
- assert.Equal(t, suiteTester.SetupTestRunCount, 3)
- assert.Equal(t, suiteTester.TearDownTestRunCount, 3)
-
- // Each test should have been run once.
- assert.Equal(t, suiteTester.TestOneRunCount, 1)
- assert.Equal(t, suiteTester.TestTwoRunCount, 1)
-
- // Methods that don't match the test method identifier shouldn't
- // have been run at all.
- assert.Equal(t, suiteTester.NonTestMethodRunCount, 0)
-
- suiteSkipTester := new(SuiteSkipTester)
- Run(t, suiteSkipTester)
-
- // The suite was only run once, so the SetupSuite and TearDownSuite
- // methods should have each been run only once, even though SetupSuite
- // called Skip()
- assert.Equal(t, suiteSkipTester.SetupSuiteRunCount, 1)
- assert.Equal(t, suiteSkipTester.TearDownSuiteRunCount, 1)
-
-}
-
-func TestSuiteGetters(t *testing.T) {
- suite := new(SuiteTester)
- suite.SetT(t)
- assert.NotNil(t, suite.Assert())
- assert.Equal(t, suite.Assertions, suite.Assert())
- assert.NotNil(t, suite.Require())
- assert.Equal(t, suite.require, suite.Require())
-}
-
-type SuiteLoggingTester struct {
- Suite
-}
-
-func (s *SuiteLoggingTester) TestLoggingPass() {
- s.T().Log("TESTLOGPASS")
-}
-
-func (s *SuiteLoggingTester) TestLoggingFail() {
- s.T().Log("TESTLOGFAIL")
- assert.NotNil(s.T(), nil) // expected to fail
-}
-
-type StdoutCapture struct {
- oldStdout *os.File
- readPipe *os.File
-}
-
-func (sc *StdoutCapture) StartCapture() {
- sc.oldStdout = os.Stdout
- sc.readPipe, os.Stdout, _ = os.Pipe()
-}
-
-func (sc *StdoutCapture) StopCapture() (string, error) {
- if sc.oldStdout == nil || sc.readPipe == nil {
- return "", errors.New("StartCapture not called before StopCapture")
- }
- os.Stdout.Close()
- os.Stdout = sc.oldStdout
- bytes, err := ioutil.ReadAll(sc.readPipe)
- if err != nil {
- return "", err
- }
- return string(bytes), nil
-}
-
-func TestSuiteLogging(t *testing.T) {
- testT := testing.T{}
-
- suiteLoggingTester := new(SuiteLoggingTester)
-
- capture := StdoutCapture{}
- capture.StartCapture()
- Run(&testT, suiteLoggingTester)
- output, err := capture.StopCapture()
-
- assert.Nil(t, err, "Got an error trying to capture stdout!")
-
- // Failed tests' output is always printed
- assert.Contains(t, output, "TESTLOGFAIL")
-
- if testing.Verbose() {
- // In verbose mode, output from successful tests is also printed
- assert.Contains(t, output, "TESTLOGPASS")
- } else {
- assert.NotContains(t, output, "TESTLOGPASS")
- }
-}