go.mod: github.com/stretchr/testify v1.8.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
		
							
								
								
									
										4
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.mod
									
									
									
									
									
								
							| @@ -48,7 +48,7 @@ require ( | ||||
| 	github.com/pelletier/go-toml v1.9.3 | ||||
| 	github.com/prometheus/client_golang v1.12.1 | ||||
| 	github.com/sirupsen/logrus v1.8.1 | ||||
| 	github.com/stretchr/testify v1.7.1 | ||||
| 	github.com/stretchr/testify v1.8.0 | ||||
| 	github.com/tchap/go-patricia/v2 v2.3.1 | ||||
| 	github.com/urfave/cli v1.22.9 | ||||
| 	github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5 | ||||
| @@ -131,7 +131,7 @@ require ( | ||||
| 	gopkg.in/inf.v0 v0.9.1 // indirect | ||||
| 	gopkg.in/square/go-jose.v2 v2.5.1 // indirect | ||||
| 	gopkg.in/yaml.v2 v2.4.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| 	sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect | ||||
| 	sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect | ||||
| 	sigs.k8s.io/yaml v1.3.0 // indirect | ||||
|   | ||||
							
								
								
									
										9
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								go.sum
									
									
									
									
									
								
							| @@ -889,8 +889,9 @@ github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag | ||||
| github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= | ||||
| github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= | ||||
| github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= | ||||
| github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||||
| github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||||
| github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||||
| github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||||
| @@ -898,8 +899,9 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P | ||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||
| github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= | ||||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= | ||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||||
| github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= | ||||
| github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= | ||||
| github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= | ||||
| @@ -1534,8 +1536,9 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||||
| gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= | ||||
| gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= | ||||
| gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= | ||||
|   | ||||
| @@ -15,7 +15,7 @@ require ( | ||||
| 	github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1 | ||||
| 	github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 | ||||
| 	github.com/sirupsen/logrus v1.8.1 | ||||
| 	github.com/stretchr/testify v1.7.1 | ||||
| 	github.com/stretchr/testify v1.8.0 | ||||
| 	golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a | ||||
| ) | ||||
|  | ||||
| @@ -64,7 +64,7 @@ require ( | ||||
| 	google.golang.org/grpc v1.47.0 // indirect | ||||
| 	google.golang.org/protobuf v1.28.0 // indirect | ||||
| 	gopkg.in/yaml.v2 v2.4.0 // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect | ||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||
| 	sigs.k8s.io/yaml v1.3.0 // indirect | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -630,14 +630,16 @@ github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= | ||||
| github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||||
| github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||||
| github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||
| github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= | ||||
| github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||
| github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= | ||||
| github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||||
| github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= | ||||
| github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI= | ||||
| github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= | ||||
| @@ -1179,8 +1181,9 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||||
| gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= | ||||
| gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||
| gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= | ||||
| gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= | ||||
| gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= | ||||
|   | ||||
							
								
								
									
										22
									
								
								vendor/github.com/stretchr/testify/assert/assertion_compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/stretchr/testify/assert/assertion_compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| package assert | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"reflect" | ||||
| 	"time" | ||||
| @@ -33,6 +34,7 @@ var ( | ||||
| 	stringType = reflect.TypeOf("") | ||||
|  | ||||
| 	timeType  = reflect.TypeOf(time.Time{}) | ||||
| 	bytesType = reflect.TypeOf([]byte{}) | ||||
| ) | ||||
|  | ||||
| func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { | ||||
| @@ -323,6 +325,26 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { | ||||
|  | ||||
| 			return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64) | ||||
| 		} | ||||
| 	case reflect.Slice: | ||||
| 		{ | ||||
| 			// We only care about the []byte type. | ||||
| 			if !canConvert(obj1Value, bytesType) { | ||||
| 				break | ||||
| 			} | ||||
|  | ||||
| 			// []byte can be compared! | ||||
| 			bytesObj1, ok := obj1.([]byte) | ||||
| 			if !ok { | ||||
| 				bytesObj1 = obj1Value.Convert(bytesType).Interface().([]byte) | ||||
|  | ||||
| 			} | ||||
| 			bytesObj2, ok := obj2.([]byte) | ||||
| 			if !ok { | ||||
| 				bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte) | ||||
| 			} | ||||
|  | ||||
| 			return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return compareEqual, false | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -9,7 +9,7 @@ package assert | ||||
|  | ||||
| import "reflect" | ||||
|  | ||||
| // Wrapper around reflect.Value.CanConvert, for compatability | ||||
| // Wrapper around reflect.Value.CanConvert, for compatibility | ||||
| // reasons. | ||||
| func canConvert(value reflect.Value, to reflect.Type) bool { | ||||
| 	return value.CanConvert(to) | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/github.com/stretchr/testify/assert/assertion_format.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/stretchr/testify/assert/assertion_format.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -736,6 +736,16 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim | ||||
| 	return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...) | ||||
| } | ||||
|  | ||||
| // WithinRangef asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") | ||||
| func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool { | ||||
| 	if h, ok := t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
| 	return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...) | ||||
| } | ||||
|  | ||||
| // YAMLEqf asserts that two YAML strings are equivalent. | ||||
| func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { | ||||
| 	if h, ok := t.(tHelper); ok { | ||||
|   | ||||
							
								
								
									
										20
									
								
								vendor/github.com/stretchr/testify/assert/assertion_forward.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/github.com/stretchr/testify/assert/assertion_forward.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1461,6 +1461,26 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta | ||||
| 	return WithinDurationf(a.t, expected, actual, delta, msg, args...) | ||||
| } | ||||
|  | ||||
| // WithinRange asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) | ||||
| func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool { | ||||
| 	if h, ok := a.t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
| 	return WithinRange(a.t, actual, start, end, msgAndArgs...) | ||||
| } | ||||
|  | ||||
| // WithinRangef asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") | ||||
| func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool { | ||||
| 	if h, ok := a.t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
| 	return WithinRangef(a.t, actual, start, end, msg, args...) | ||||
| } | ||||
|  | ||||
| // YAMLEq asserts that two YAML strings are equivalent. | ||||
| func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool { | ||||
| 	if h, ok := a.t.(tHelper); ok { | ||||
|   | ||||
							
								
								
									
										74
									
								
								vendor/github.com/stretchr/testify/assert/assertions.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										74
									
								
								vendor/github.com/stretchr/testify/assert/assertions.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -8,6 +8,7 @@ import ( | ||||
| 	"fmt" | ||||
| 	"math" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"reflect" | ||||
| 	"regexp" | ||||
| 	"runtime" | ||||
| @@ -144,7 +145,8 @@ func CallerInfo() []string { | ||||
| 		if len(parts) > 1 { | ||||
| 			dir := parts[len(parts)-2] | ||||
| 			if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { | ||||
| 				callers = append(callers, fmt.Sprintf("%s:%d", file, line)) | ||||
| 				path, _ := filepath.Abs(file) | ||||
| 				callers = append(callers, fmt.Sprintf("%s:%d", path, line)) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| @@ -563,7 +565,7 @@ func isEmpty(object interface{}) bool { | ||||
|  | ||||
| 	switch objValue.Kind() { | ||||
| 	// collection types are empty when they have no element | ||||
| 	case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: | ||||
| 	case reflect.Chan, reflect.Map, reflect.Slice: | ||||
| 		return objValue.Len() == 0 | ||||
| 	// pointers are empty if nil or if the value they point to is empty | ||||
| 	case reflect.Ptr: | ||||
| @@ -573,6 +575,7 @@ func isEmpty(object interface{}) bool { | ||||
| 		deref := objValue.Elem().Interface() | ||||
| 		return isEmpty(deref) | ||||
| 	// for all other types, compare against the zero value | ||||
| 	// array types are empty when they match their zero-initialized state | ||||
| 	default: | ||||
| 		zero := reflect.Zero(objValue.Type()) | ||||
| 		return reflect.DeepEqual(object, zero.Interface()) | ||||
| @@ -815,7 +818,6 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok | ||||
| 		return true // we consider nil to be equal to the nil set | ||||
| 	} | ||||
|  | ||||
| 	subsetValue := reflect.ValueOf(subset) | ||||
| 	defer func() { | ||||
| 		if e := recover(); e != nil { | ||||
| 			ok = false | ||||
| @@ -825,14 +827,32 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok | ||||
| 	listKind := reflect.TypeOf(list).Kind() | ||||
| 	subsetKind := reflect.TypeOf(subset).Kind() | ||||
|  | ||||
| 	if listKind != reflect.Array && listKind != reflect.Slice { | ||||
| 	if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { | ||||
| 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) | ||||
| 	} | ||||
|  | ||||
| 	if subsetKind != reflect.Array && subsetKind != reflect.Slice { | ||||
| 	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() | ||||
|  | ||||
| 		for i := 0; i < len(subsetKeys); i++ { | ||||
| 			subsetKey := subsetKeys[i] | ||||
| 			subsetElement := subsetValue.MapIndex(subsetKey).Interface() | ||||
| 			listElement := listValue.MapIndex(subsetKey).Interface() | ||||
|  | ||||
| 			if !ObjectsAreEqual(subsetElement, listElement) { | ||||
| 				return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, subsetElement), msgAndArgs...) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return true | ||||
| 	} | ||||
|  | ||||
| 	for i := 0; i < subsetValue.Len(); i++ { | ||||
| 		element := subsetValue.Index(i).Interface() | ||||
| 		ok, found := containsElement(list, element) | ||||
| @@ -859,7 +879,6 @@ 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...) | ||||
| 	} | ||||
|  | ||||
| 	subsetValue := reflect.ValueOf(subset) | ||||
| 	defer func() { | ||||
| 		if e := recover(); e != nil { | ||||
| 			ok = false | ||||
| @@ -869,14 +888,32 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) | ||||
| 	listKind := reflect.TypeOf(list).Kind() | ||||
| 	subsetKind := reflect.TypeOf(subset).Kind() | ||||
|  | ||||
| 	if listKind != reflect.Array && listKind != reflect.Slice { | ||||
| 	if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { | ||||
| 		return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) | ||||
| 	} | ||||
|  | ||||
| 	if subsetKind != reflect.Array && subsetKind != reflect.Slice { | ||||
| 	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() | ||||
|  | ||||
| 		for i := 0; i < len(subsetKeys); i++ { | ||||
| 			subsetKey := subsetKeys[i] | ||||
| 			subsetElement := subsetValue.MapIndex(subsetKey).Interface() | ||||
| 			listElement := listValue.MapIndex(subsetKey).Interface() | ||||
|  | ||||
| 			if !ObjectsAreEqual(subsetElement, listElement) { | ||||
| 				return true | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		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() | ||||
| 		ok, found := containsElement(list, element) | ||||
| @@ -1109,6 +1146,27 @@ func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // WithinRange asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) | ||||
| func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool { | ||||
| 	if h, ok := t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
|  | ||||
| 	if end.Before(start) { | ||||
| 		return Fail(t, "Start should be before end", msgAndArgs...) | ||||
| 	} | ||||
|  | ||||
| 	if actual.Before(start) { | ||||
| 		return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is before the range", actual, start, end), msgAndArgs...) | ||||
| 	} else if actual.After(end) { | ||||
| 		return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is after the range", actual, start, end), msgAndArgs...) | ||||
| 	} | ||||
|  | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| func toFloat(x interface{}) (float64, bool) { | ||||
| 	var xf float64 | ||||
| 	xok := true | ||||
|   | ||||
							
								
								
									
										26
									
								
								vendor/github.com/stretchr/testify/require/require.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/stretchr/testify/require/require.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1864,6 +1864,32 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim | ||||
| 	t.FailNow() | ||||
| } | ||||
|  | ||||
| // WithinRange asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) | ||||
| func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) { | ||||
| 	if h, ok := t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
| 	if assert.WithinRange(t, actual, start, end, msgAndArgs...) { | ||||
| 		return | ||||
| 	} | ||||
| 	t.FailNow() | ||||
| } | ||||
|  | ||||
| // WithinRangef asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") | ||||
| func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) { | ||||
| 	if h, ok := t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
| 	if assert.WithinRangef(t, actual, start, end, msg, args...) { | ||||
| 		return | ||||
| 	} | ||||
| 	t.FailNow() | ||||
| } | ||||
|  | ||||
| // YAMLEq asserts that two YAML strings are equivalent. | ||||
| func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { | ||||
| 	if h, ok := t.(tHelper); ok { | ||||
|   | ||||
							
								
								
									
										20
									
								
								vendor/github.com/stretchr/testify/require/require_forward.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/github.com/stretchr/testify/require/require_forward.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1462,6 +1462,26 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta | ||||
| 	WithinDurationf(a.t, expected, actual, delta, msg, args...) | ||||
| } | ||||
|  | ||||
| // WithinRange asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) | ||||
| func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) { | ||||
| 	if h, ok := a.t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
| 	WithinRange(a.t, actual, start, end, msgAndArgs...) | ||||
| } | ||||
|  | ||||
| // WithinRangef asserts that a time is within a time range (inclusive). | ||||
| // | ||||
| //   a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") | ||||
| func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) { | ||||
| 	if h, ok := a.t.(tHelper); ok { | ||||
| 		h.Helper() | ||||
| 	} | ||||
| 	WithinRangef(a.t, actual, start, end, msg, args...) | ||||
| } | ||||
|  | ||||
| // YAMLEq asserts that two YAML strings are equivalent. | ||||
| func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) { | ||||
| 	if h, ok := a.t.(tHelper); ok { | ||||
|   | ||||
							
								
								
									
										78
									
								
								vendor/gopkg.in/yaml.v3/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										78
									
								
								vendor/gopkg.in/yaml.v3/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -100,7 +100,10 @@ func (p *parser) peek() yaml_event_type_t { | ||||
| 	if p.event.typ != yaml_NO_EVENT { | ||||
| 		return p.event.typ | ||||
| 	} | ||||
| 	if !yaml_parser_parse(&p.parser, &p.event) { | ||||
| 	// It's curious choice from the underlying API to generally return a | ||||
| 	// positive result on success, but on this case return true in an error | ||||
| 	// scenario. This was the source of bugs in the past (issue #666). | ||||
| 	if !yaml_parser_parse(&p.parser, &p.event) || p.parser.error != yaml_NO_ERROR { | ||||
| 		p.fail() | ||||
| 	} | ||||
| 	return p.event.typ | ||||
| @@ -320,6 +323,8 @@ type decoder struct { | ||||
| 	decodeCount int | ||||
| 	aliasCount  int | ||||
| 	aliasDepth  int | ||||
|  | ||||
| 	mergedFields map[interface{}]bool | ||||
| } | ||||
|  | ||||
| var ( | ||||
| @@ -808,6 +813,11 @@ func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	mergedFields := d.mergedFields | ||||
| 	d.mergedFields = nil | ||||
|  | ||||
| 	var mergeNode *Node | ||||
|  | ||||
| 	mapIsNew := false | ||||
| 	if out.IsNil() { | ||||
| 		out.Set(reflect.MakeMap(outt)) | ||||
| @@ -815,11 +825,18 @@ func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) { | ||||
| 	} | ||||
| 	for i := 0; i < l; i += 2 { | ||||
| 		if isMerge(n.Content[i]) { | ||||
| 			d.merge(n.Content[i+1], out) | ||||
| 			mergeNode = n.Content[i+1] | ||||
| 			continue | ||||
| 		} | ||||
| 		k := reflect.New(kt).Elem() | ||||
| 		if d.unmarshal(n.Content[i], k) { | ||||
| 			if mergedFields != nil { | ||||
| 				ki := k.Interface() | ||||
| 				if mergedFields[ki] { | ||||
| 					continue | ||||
| 				} | ||||
| 				mergedFields[ki] = true | ||||
| 			} | ||||
| 			kkind := k.Kind() | ||||
| 			if kkind == reflect.Interface { | ||||
| 				kkind = k.Elem().Kind() | ||||
| @@ -833,6 +850,12 @@ func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) { | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	d.mergedFields = mergedFields | ||||
| 	if mergeNode != nil { | ||||
| 		d.merge(n, mergeNode, out) | ||||
| 	} | ||||
|  | ||||
| 	d.stringMapType = stringMapType | ||||
| 	d.generalMapType = generalMapType | ||||
| 	return true | ||||
| @@ -844,7 +867,8 @@ func isStringMap(n *Node) bool { | ||||
| 	} | ||||
| 	l := len(n.Content) | ||||
| 	for i := 0; i < l; i += 2 { | ||||
| 		if n.Content[i].ShortTag() != strTag { | ||||
| 		shortTag := n.Content[i].ShortTag() | ||||
| 		if shortTag != strTag && shortTag != mergeTag { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
| @@ -861,7 +885,6 @@ func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) { | ||||
| 	var elemType reflect.Type | ||||
| 	if sinfo.InlineMap != -1 { | ||||
| 		inlineMap = out.Field(sinfo.InlineMap) | ||||
| 		inlineMap.Set(reflect.New(inlineMap.Type()).Elem()) | ||||
| 		elemType = inlineMap.Type().Elem() | ||||
| 	} | ||||
|  | ||||
| @@ -870,6 +893,9 @@ func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) { | ||||
| 		d.prepare(n, field) | ||||
| 	} | ||||
|  | ||||
| 	mergedFields := d.mergedFields | ||||
| 	d.mergedFields = nil | ||||
| 	var mergeNode *Node | ||||
| 	var doneFields []bool | ||||
| 	if d.uniqueKeys { | ||||
| 		doneFields = make([]bool, len(sinfo.FieldsList)) | ||||
| @@ -879,13 +905,20 @@ func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) { | ||||
| 	for i := 0; i < l; i += 2 { | ||||
| 		ni := n.Content[i] | ||||
| 		if isMerge(ni) { | ||||
| 			d.merge(n.Content[i+1], out) | ||||
| 			mergeNode = n.Content[i+1] | ||||
| 			continue | ||||
| 		} | ||||
| 		if !d.unmarshal(ni, name) { | ||||
| 			continue | ||||
| 		} | ||||
| 		if info, ok := sinfo.FieldsMap[name.String()]; ok { | ||||
| 		sname := name.String() | ||||
| 		if mergedFields != nil { | ||||
| 			if mergedFields[sname] { | ||||
| 				continue | ||||
| 			} | ||||
| 			mergedFields[sname] = true | ||||
| 		} | ||||
| 		if info, ok := sinfo.FieldsMap[sname]; ok { | ||||
| 			if d.uniqueKeys { | ||||
| 				if doneFields[info.Id] { | ||||
| 					d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s already set in type %s", ni.Line, name.String(), out.Type())) | ||||
| @@ -911,6 +944,11 @@ func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) { | ||||
| 			d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in type %s", ni.Line, name.String(), out.Type())) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	d.mergedFields = mergedFields | ||||
| 	if mergeNode != nil { | ||||
| 		d.merge(n, mergeNode, out) | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| @@ -918,19 +956,29 @@ func failWantMap() { | ||||
| 	failf("map merge requires map or sequence of maps as the value") | ||||
| } | ||||
|  | ||||
| func (d *decoder) merge(n *Node, out reflect.Value) { | ||||
| 	switch n.Kind { | ||||
| func (d *decoder) merge(parent *Node, merge *Node, out reflect.Value) { | ||||
| 	mergedFields := d.mergedFields | ||||
| 	if mergedFields == nil { | ||||
| 		d.mergedFields = make(map[interface{}]bool) | ||||
| 		for i := 0; i < len(parent.Content); i += 2 { | ||||
| 			k := reflect.New(ifaceType).Elem() | ||||
| 			if d.unmarshal(parent.Content[i], k) { | ||||
| 				d.mergedFields[k.Interface()] = true | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	switch merge.Kind { | ||||
| 	case MappingNode: | ||||
| 		d.unmarshal(n, out) | ||||
| 		d.unmarshal(merge, out) | ||||
| 	case AliasNode: | ||||
| 		if n.Alias != nil && n.Alias.Kind != MappingNode { | ||||
| 		if merge.Alias != nil && merge.Alias.Kind != MappingNode { | ||||
| 			failWantMap() | ||||
| 		} | ||||
| 		d.unmarshal(n, out) | ||||
| 		d.unmarshal(merge, out) | ||||
| 	case SequenceNode: | ||||
| 		// Step backwards as earlier nodes take precedence. | ||||
| 		for i := len(n.Content) - 1; i >= 0; i-- { | ||||
| 			ni := n.Content[i] | ||||
| 		for i := 0; i < len(merge.Content); i++ { | ||||
| 			ni := merge.Content[i] | ||||
| 			if ni.Kind == AliasNode { | ||||
| 				if ni.Alias != nil && ni.Alias.Kind != MappingNode { | ||||
| 					failWantMap() | ||||
| @@ -943,6 +991,8 @@ func (d *decoder) merge(n *Node, out reflect.Value) { | ||||
| 	default: | ||||
| 		failWantMap() | ||||
| 	} | ||||
|  | ||||
| 	d.mergedFields = mergedFields | ||||
| } | ||||
|  | ||||
| func isMerge(n *Node) bool { | ||||
|   | ||||
							
								
								
									
										11
									
								
								vendor/gopkg.in/yaml.v3/parserc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								vendor/gopkg.in/yaml.v3/parserc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -687,6 +687,9 @@ func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, i | ||||
| func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { | ||||
| 	if first { | ||||
| 		token := peek_token(parser) | ||||
| 		if token == nil { | ||||
| 			return false | ||||
| 		} | ||||
| 		parser.marks = append(parser.marks, token.start_mark) | ||||
| 		skip_token(parser) | ||||
| 	} | ||||
| @@ -786,7 +789,7 @@ func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) { | ||||
| 	} | ||||
|  | ||||
| 	token := peek_token(parser) | ||||
| 	if token.typ != yaml_BLOCK_SEQUENCE_START_TOKEN && token.typ != yaml_BLOCK_MAPPING_START_TOKEN { | ||||
| 	if token == nil || token.typ != yaml_BLOCK_SEQUENCE_START_TOKEN && token.typ != yaml_BLOCK_MAPPING_START_TOKEN { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| @@ -813,6 +816,9 @@ func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) { | ||||
| func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { | ||||
| 	if first { | ||||
| 		token := peek_token(parser) | ||||
| 		if token == nil { | ||||
| 			return false | ||||
| 		} | ||||
| 		parser.marks = append(parser.marks, token.start_mark) | ||||
| 		skip_token(parser) | ||||
| 	} | ||||
| @@ -922,6 +928,9 @@ func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_ev | ||||
| func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { | ||||
| 	if first { | ||||
| 		token := peek_token(parser) | ||||
| 		if token == nil { | ||||
| 			return false | ||||
| 		} | ||||
| 		parser.marks = append(parser.marks, token.start_mark) | ||||
| 		skip_token(parser) | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							| @@ -372,7 +372,7 @@ github.com/spf13/pflag | ||||
| # github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 | ||||
| ## explicit | ||||
| github.com/stefanberger/go-pkcs11uri | ||||
| # github.com/stretchr/testify v1.7.1 | ||||
| # github.com/stretchr/testify v1.8.0 | ||||
| ## explicit; go 1.13 | ||||
| github.com/stretchr/testify/assert | ||||
| github.com/stretchr/testify/require | ||||
| @@ -637,7 +637,7 @@ gopkg.in/square/go-jose.v2/json | ||||
| # gopkg.in/yaml.v2 v2.4.0 | ||||
| ## explicit; go 1.15 | ||||
| gopkg.in/yaml.v2 | ||||
| # gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b | ||||
| # gopkg.in/yaml.v3 v3.0.1 | ||||
| ## explicit | ||||
| gopkg.in/yaml.v3 | ||||
| # k8s.io/api v0.24.1 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Akihiro Suda
					Akihiro Suda