diff options
Diffstat (limited to 'vendor')
| -rw-r--r-- | vendor/github.com/stretchr/testify/assert/assertions.go | 78 | ||||
| -rw-r--r-- | vendor/github.com/stretchr/testify/suite/interfaces.go | 13 | ||||
| -rw-r--r-- | vendor/github.com/stretchr/testify/suite/suite.go | 24 | ||||
| -rw-r--r-- | vendor/modules.txt | 2 | 
4 files changed, 70 insertions, 47 deletions
diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index fa1245b18..2924cf3a1 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -8,7 +8,6 @@ import (  	"fmt"  	"math"  	"os" -	"path/filepath"  	"reflect"  	"regexp"  	"runtime" @@ -141,12 +140,11 @@ func CallerInfo() []string {  		}  		parts := strings.Split(file, "/") -		file = parts[len(parts)-1]  		if len(parts) > 1 { +			filename := parts[len(parts)-1]  			dir := parts[len(parts)-2] -			if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { -				path, _ := filepath.Abs(file) -				callers = append(callers, fmt.Sprintf("%s:%d", path, line)) +			if (dir != "assert" && dir != "mock" && dir != "require") || filename == "mock_test.go" { +				callers = append(callers, fmt.Sprintf("%s:%d", file, line))  			}  		} @@ -530,7 +528,7 @@ func isNil(object interface{}) bool {  		[]reflect.Kind{  			reflect.Chan, reflect.Func,  			reflect.Interface, reflect.Map, -			reflect.Ptr, reflect.Slice}, +			reflect.Ptr, reflect.Slice, reflect.UnsafePointer},  		kind)  	if isNilableKind && value.IsNil() { @@ -818,49 +816,44 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok  		return true // we consider nil to be equal to the nil set  	} -	defer func() { -		if e := recover(); e != nil { -			ok = false -		} -	}() -  	listKind := reflect.TypeOf(list).Kind() -	subsetKind := reflect.TypeOf(subset).Kind() -  	if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {  		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)  	} +	subsetKind := reflect.TypeOf(subset).Kind()  	if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {  		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)  	} -	subsetValue := reflect.ValueOf(subset)  	if subsetKind == reflect.Map && listKind == reflect.Map { -		listValue := reflect.ValueOf(list) -		subsetKeys := subsetValue.MapKeys() +		subsetMap := reflect.ValueOf(subset) +		actualMap := reflect.ValueOf(list) -		for i := 0; i < len(subsetKeys); i++ { -			subsetKey := subsetKeys[i] -			subsetElement := subsetValue.MapIndex(subsetKey).Interface() -			listElement := listValue.MapIndex(subsetKey).Interface() +		for _, k := range subsetMap.MapKeys() { +			ev := subsetMap.MapIndex(k) +			av := actualMap.MapIndex(k) -			if !ObjectsAreEqual(subsetElement, listElement) { -				return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, subsetElement), msgAndArgs...) +			if !av.IsValid() { +				return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) +			} +			if !ObjectsAreEqual(ev.Interface(), av.Interface()) { +				return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...)  			}  		}  		return true  	} -	for i := 0; i < subsetValue.Len(); i++ { -		element := subsetValue.Index(i).Interface() +	subsetList := reflect.ValueOf(subset) +	for i := 0; i < subsetList.Len(); i++ { +		element := subsetList.Index(i).Interface()  		ok, found := containsElement(list, element)  		if !ok { -			return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) +			return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", list), msgAndArgs...)  		}  		if !found { -			return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...) +			return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, element), msgAndArgs...)  		}  	} @@ -879,34 +872,28 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})  		return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...)  	} -	defer func() { -		if e := recover(); e != nil { -			ok = false -		} -	}() -  	listKind := reflect.TypeOf(list).Kind() -	subsetKind := reflect.TypeOf(subset).Kind() -  	if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {  		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)  	} +	subsetKind := reflect.TypeOf(subset).Kind()  	if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map {  		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)  	} -	subsetValue := reflect.ValueOf(subset)  	if subsetKind == reflect.Map && listKind == reflect.Map { -		listValue := reflect.ValueOf(list) -		subsetKeys := subsetValue.MapKeys() +		subsetMap := reflect.ValueOf(subset) +		actualMap := reflect.ValueOf(list) -		for i := 0; i < len(subsetKeys); i++ { -			subsetKey := subsetKeys[i] -			subsetElement := subsetValue.MapIndex(subsetKey).Interface() -			listElement := listValue.MapIndex(subsetKey).Interface() +		for _, k := range subsetMap.MapKeys() { +			ev := subsetMap.MapIndex(k) +			av := actualMap.MapIndex(k) -			if !ObjectsAreEqual(subsetElement, listElement) { +			if !av.IsValid() { +				return true +			} +			if !ObjectsAreEqual(ev.Interface(), av.Interface()) {  				return true  			}  		} @@ -914,8 +901,9 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})  		return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...)  	} -	for i := 0; i < subsetValue.Len(); i++ { -		element := subsetValue.Index(i).Interface() +	subsetList := reflect.ValueOf(subset) +	for i := 0; i < subsetList.Len(); i++ { +		element := subsetList.Index(i).Interface()  		ok, found := containsElement(list, element)  		if !ok {  			return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) diff --git a/vendor/github.com/stretchr/testify/suite/interfaces.go b/vendor/github.com/stretchr/testify/suite/interfaces.go index 8b98a8af2..fed037d7f 100644 --- a/vendor/github.com/stretchr/testify/suite/interfaces.go +++ b/vendor/github.com/stretchr/testify/suite/interfaces.go @@ -7,6 +7,7 @@ import "testing"  type TestingSuite interface {  	T() *testing.T  	SetT(*testing.T) +	SetS(suite TestingSuite)  }  // SetupAllSuite has a SetupSuite method, which will run before the @@ -51,3 +52,15 @@ type AfterTest interface {  type WithStats interface {  	HandleStats(suiteName string, stats *SuiteInformation)  } + +// SetupSubTest has a SetupSubTest method, which will run before each +// subtest in the suite. +type SetupSubTest interface { +	SetupSubTest() +} + +// TearDownSubTest has a TearDownSubTest method, which will run after +// each subtest in the suite have been run. +type TearDownSubTest interface { +	TearDownSubTest() +} diff --git a/vendor/github.com/stretchr/testify/suite/suite.go b/vendor/github.com/stretchr/testify/suite/suite.go index 895591878..8b4202d89 100644 --- a/vendor/github.com/stretchr/testify/suite/suite.go +++ b/vendor/github.com/stretchr/testify/suite/suite.go @@ -22,9 +22,13 @@ var matchMethod = flag.String("testify.m", "", "regular expression to select tes  // retrieving the current *testing.T context.  type Suite struct {  	*assert.Assertions +  	mu      sync.RWMutex  	require *require.Assertions  	t       *testing.T + +	// Parent suite to have access to the implemented methods of parent struct +	s TestingSuite  }  // T retrieves the current *testing.T context. @@ -43,6 +47,12 @@ func (suite *Suite) SetT(t *testing.T) {  	suite.require = require.New(t)  } +// SetS needs to set the current test suite as parent +// to get access to the parent methods +func (suite *Suite) SetS(s TestingSuite) { +	suite.s = s +} +  // Require returns a require context for suite.  func (suite *Suite) Require() *require.Assertions {  	suite.mu.Lock() @@ -85,7 +95,18 @@ func failOnPanic(t *testing.T, r interface{}) {  // Provides compatibility with go test pkg -run TestSuite/TestName/SubTestName.  func (suite *Suite) Run(name string, subtest func()) bool {  	oldT := suite.T() -	defer suite.SetT(oldT) + +	if setupSubTest, ok := suite.s.(SetupSubTest); ok { +		setupSubTest.SetupSubTest() +	} + +	defer func() { +		suite.SetT(oldT) +		if tearDownSubTest, ok := suite.s.(TearDownSubTest); ok { +			tearDownSubTest.TearDownSubTest() +		} +	}() +  	return oldT.Run(name, func(t *testing.T) {  		suite.SetT(t)  		subtest() @@ -98,6 +119,7 @@ func Run(t *testing.T, suite TestingSuite) {  	defer recoverAndFailOnPanic(t)  	suite.SetT(t) +	suite.SetS(suite)  	var suiteSetupDone bool diff --git a/vendor/modules.txt b/vendor/modules.txt index ca6d99f33..037d733b6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -440,7 +440,7 @@ github.com/spf13/viper/internal/encoding/javaproperties  github.com/spf13/viper/internal/encoding/json  github.com/spf13/viper/internal/encoding/toml  github.com/spf13/viper/internal/encoding/yaml -# github.com/stretchr/testify v1.8.1 +# github.com/stretchr/testify v1.8.2  ## explicit; go 1.13  github.com/stretchr/testify/assert  github.com/stretchr/testify/require  | 
