Merge pull request #10879 from containers/dependabot/go_modules/github.com/onsi/gomega-1.14.0
Bump github.com/onsi/gomega from 1.13.0 to 1.14.0
This commit is contained in:
		
						commit
						dd2ca4bad4
					
				
							
								
								
									
										2
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										2
									
								
								go.mod
								
								
								
								
							|  | @ -43,7 +43,7 @@ require ( | ||||||
| 	github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 | 	github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 | ||||||
| 	github.com/mrunalp/fileutils v0.5.0 | 	github.com/mrunalp/fileutils v0.5.0 | ||||||
| 	github.com/onsi/ginkgo v1.16.4 | 	github.com/onsi/ginkgo v1.16.4 | ||||||
| 	github.com/onsi/gomega v1.13.0 | 	github.com/onsi/gomega v1.14.0 | ||||||
| 	github.com/opencontainers/go-digest v1.0.0 | 	github.com/opencontainers/go-digest v1.0.0 | ||||||
| 	github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 | 	github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 | ||||||
| 	github.com/opencontainers/runc v1.0.0 | 	github.com/opencontainers/runc v1.0.0 | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										3
									
								
								go.sum
								
								
								
								
							|  | @ -705,8 +705,9 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J | ||||||
| github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | ||||||
| github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= | github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= | ||||||
| github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= | github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= | ||||||
| github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= |  | ||||||
| github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= | github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= | ||||||
|  | github.com/onsi/gomega v1.14.0 h1:ep6kpPVwmr/nTbklSx2nrLNSIO62DoYAhnPNIMhK8gI= | ||||||
|  | github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= | ||||||
| github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= | github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= | ||||||
| github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= | github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= | ||||||
| github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= | github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= | ||||||
|  |  | ||||||
|  | @ -1,3 +1,20 @@ | ||||||
|  | ## 1.14.0 | ||||||
|  | 
 | ||||||
|  | ### Features | ||||||
|  | - gmeasure.SamplingConfig now suppers a MinSamplingInterval [e94dbca] | ||||||
|  | - Eventually and Consistently support functions that make assertions [2f04e6e] | ||||||
|  |     - Eventually and Consistently now allow their passed-in functions to make assertions. | ||||||
|  |     These assertions must pass or the function is considered to have failed and is retried. | ||||||
|  |     - Eventually and Consistently can now take functions with no return values.  These implicitly return nil | ||||||
|  |     if they contain no failed assertion.  Otherwise they return an error wrapping the first assertion failure.  This allows | ||||||
|  |     these functions to be used with the Succeed() matcher. | ||||||
|  |     - Introduce InterceptGomegaFailure - an analogue to InterceptGomegaFailures - that captures the first assertion failure | ||||||
|  |     and halts execution in its passed-in callback. | ||||||
|  | 
 | ||||||
|  | ### Fixes | ||||||
|  | - Call Verify GHTTPWithGomega receiver funcs (#454) [496e6fd] | ||||||
|  | - Build a binary with an expected name (#446) [7356360] | ||||||
|  | 
 | ||||||
| ## 1.13.0 | ## 1.13.0 | ||||||
| 
 | 
 | ||||||
| ### Features | ### Features | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
|  |  | ||||||
| 
 | 
 | ||||||
| [](https://travis-ci.org/onsi/gomega) | [](https://github.com/onsi/gomega/actions/workflows/test.yml) | ||||||
| 
 | 
 | ||||||
| Jump straight to the [docs](http://onsi.github.io/gomega/) to learn about Gomega, including a list of [all available matchers](http://onsi.github.io/gomega/#provided-matchers). | Jump straight to the [docs](http://onsi.github.io/gomega/) to learn about Gomega, including a list of [all available matchers](http://onsi.github.io/gomega/#provided-matchers). | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,8 +3,6 @@ | ||||||
| package gexec | package gexec | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"crypto/md5" |  | ||||||
| 	"encoding/hex" |  | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"go/build" | 	"go/build" | ||||||
|  | @ -197,9 +195,7 @@ func newExecutablePath(gopath, packagePath string, suffixes ...string) (string, | ||||||
| 		return "", errors.New("$GOPATH not provided when building " + packagePath) | 		return "", errors.New("$GOPATH not provided when building " + packagePath) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	hash := md5.Sum([]byte(packagePath)) | 	executable := filepath.Join(tmpDir, path.Base(packagePath)) | ||||||
| 	filename := fmt.Sprintf("%s-%x%s", path.Base(packagePath), hex.EncodeToString(hash[:]), strings.Join(suffixes, "")) |  | ||||||
| 	executable := filepath.Join(tmpDir, filename) |  | ||||||
| 
 | 
 | ||||||
| 	if runtime.GOOS == "windows" { | 	if runtime.GOOS == "windows" { | ||||||
| 		executable += ".exe" | 		executable += ".exe" | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ go 1.14 | ||||||
| 
 | 
 | ||||||
| require ( | require ( | ||||||
| 	github.com/golang/protobuf v1.5.2 | 	github.com/golang/protobuf v1.5.2 | ||||||
| 	github.com/onsi/ginkgo v1.16.2 | 	github.com/onsi/ginkgo v1.16.4 | ||||||
| 	golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 | 	golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 | ||||||
| 	gopkg.in/yaml.v2 v2.4.0 | 	gopkg.in/yaml.v2 v2.4.0 | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs | ||||||
| github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= | ||||||
| github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= | github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= | ||||||
| github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= | github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= | ||||||
|  | github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= | ||||||
| github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= | github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= | ||||||
| github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||||
| github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= | ||||||
|  | @ -25,8 +26,8 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= | ||||||
| github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= | github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= | ||||||
| github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | ||||||
| github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= | github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= | ||||||
| github.com/onsi/ginkgo v1.16.2 h1:HFB2fbVIlhIfCfOW81bZFbiC/RvnpXSdhbF2/DJr134= | github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= | ||||||
| github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= | github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= | ||||||
| github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= | ||||||
| github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | ||||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||||
|  | @ -66,6 +67,7 @@ golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= | ||||||
| golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||||
|  | golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e h1:4nW4NLDYnU28ojHaHO8OVxFHk/aQ33U01a9cjED+pzE= | ||||||
| golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | ||||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||||
|  |  | ||||||
|  | @ -14,6 +14,7 @@ Gomega is MIT-Licensed | ||||||
| package gomega | package gomega | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"time" | 	"time" | ||||||
|  | @ -24,7 +25,7 @@ import ( | ||||||
| 	"github.com/onsi/gomega/types" | 	"github.com/onsi/gomega/types" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const GOMEGA_VERSION = "1.13.0" | const GOMEGA_VERSION = "1.14.0" | ||||||
| 
 | 
 | ||||||
| const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil. | const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil. | ||||||
| If you're using Ginkgo then you probably forgot to put your assertion in an It(). | If you're using Ginkgo then you probably forgot to put your assertion in an It(). | ||||||
|  | @ -91,10 +92,8 @@ func RegisterTestingT(t types.GomegaTestingT) { | ||||||
| 
 | 
 | ||||||
| // InterceptGomegaFailures runs a given callback and returns an array of
 | // InterceptGomegaFailures runs a given callback and returns an array of
 | ||||||
| // failure messages generated by any Gomega assertions within the callback.
 | // failure messages generated by any Gomega assertions within the callback.
 | ||||||
| //
 | // Exeuction continues after the first failure allowing users to collect all failures
 | ||||||
| // This is accomplished by temporarily replacing the *global* fail handler
 | // in the callback.
 | ||||||
| // with a fail handler that simply annotates failures.  The original fail handler
 |  | ||||||
| // is reset when InterceptGomegaFailures returns.
 |  | ||||||
| //
 | //
 | ||||||
| // This is most useful when testing custom matchers, but can also be used to check
 | // This is most useful when testing custom matchers, but can also be used to check
 | ||||||
| // on a value using a Gomega assertion without causing a test failure.
 | // on a value using a Gomega assertion without causing a test failure.
 | ||||||
|  | @ -104,11 +103,39 @@ func InterceptGomegaFailures(f func()) []string { | ||||||
| 	RegisterFailHandler(func(message string, callerSkip ...int) { | 	RegisterFailHandler(func(message string, callerSkip ...int) { | ||||||
| 		failures = append(failures, message) | 		failures = append(failures, message) | ||||||
| 	}) | 	}) | ||||||
|  | 	defer func() { | ||||||
|  | 		RegisterFailHandler(originalHandler) | ||||||
|  | 	}() | ||||||
| 	f() | 	f() | ||||||
| 	RegisterFailHandler(originalHandler) |  | ||||||
| 	return failures | 	return failures | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // InterceptGomegaFailure runs a given callback and returns the first
 | ||||||
|  | // failure message generated by any Gomega assertions within the callback, wrapped in an error.
 | ||||||
|  | //
 | ||||||
|  | // The callback ceases execution as soon as the first failed assertion occurs, however Gomega
 | ||||||
|  | // does not register a failure with the FailHandler registered via RegisterFailHandler - it is up
 | ||||||
|  | // to the user to decide what to do with the returned error
 | ||||||
|  | func InterceptGomegaFailure(f func()) (err error) { | ||||||
|  | 	originalHandler := globalFailWrapper.Fail | ||||||
|  | 	RegisterFailHandler(func(message string, callerSkip ...int) { | ||||||
|  | 		err = errors.New(message) | ||||||
|  | 		panic("stop execution") | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
|  | 	defer func() { | ||||||
|  | 		RegisterFailHandler(originalHandler) | ||||||
|  | 		if e := recover(); e != nil { | ||||||
|  | 			if err == nil { | ||||||
|  | 				panic(e) | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | 
 | ||||||
|  | 	f() | ||||||
|  | 	return err | ||||||
|  | } | ||||||
|  | 
 | ||||||
| // Ω wraps an actual value allowing assertions to be made on it:
 | // Ω wraps an actual value allowing assertions to be made on it:
 | ||||||
| //    Ω("foo").Should(Equal("foo"))
 | //    Ω("foo").Should(Equal("foo"))
 | ||||||
| //
 | //
 | ||||||
|  | @ -177,7 +204,7 @@ func ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Asse | ||||||
| // Both intervals can either be specified as time.Duration, parsable duration strings or as floats/integers.  In the
 | // Both intervals can either be specified as time.Duration, parsable duration strings or as floats/integers.  In the
 | ||||||
| // last case they are interpreted as seconds.
 | // last case they are interpreted as seconds.
 | ||||||
| //
 | //
 | ||||||
| // If Eventually is passed an actual that is a function taking no arguments and returning at least one value,
 | // If Eventually is passed an actual that is a function taking no arguments,
 | ||||||
| // then Eventually will call the function periodically and try the matcher against the function's first return value.
 | // then Eventually will call the function periodically and try the matcher against the function's first return value.
 | ||||||
| //
 | //
 | ||||||
| // Example:
 | // Example:
 | ||||||
|  | @ -202,6 +229,34 @@ func ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Asse | ||||||
| //
 | //
 | ||||||
| // Will pass only if the the returned error is nil and the returned string passes the matcher.
 | // Will pass only if the the returned error is nil and the returned string passes the matcher.
 | ||||||
| //
 | //
 | ||||||
|  | // Eventually allows you to make assertions in the pased-in function.  The function is assumed to have failed and will be retried if any assertion in the function fails.
 | ||||||
|  | // For example:
 | ||||||
|  | //
 | ||||||
|  | //     Eventually(func() Widget {
 | ||||||
|  | //	     resp, err := http.Get(url)
 | ||||||
|  | //       Expect(err).NotTo(HaveOccurred())
 | ||||||
|  | //       defer resp.Body.Close()
 | ||||||
|  | //       Expect(resp.SatusCode).To(Equal(http.StatusOK))
 | ||||||
|  | //       var widget Widget
 | ||||||
|  | //       Expect(json.NewDecoder(resp.Body).Decode(&widget)).To(Succeed())
 | ||||||
|  | //       return widget
 | ||||||
|  | //     }).Should(Equal(expectedWidget))
 | ||||||
|  | //
 | ||||||
|  | // will keep trying the passed-in function until all its assertsions pass (i.e. the http request succeeds) _and_ the returned object satisfies the passed-in matcher.
 | ||||||
|  | //
 | ||||||
|  | // Functions passed to Eventually typically have a return value.  However you are allowed to pass in a function with no return value.  Eventually assumes such a function
 | ||||||
|  | // is making assertions and will turn it into a function that returns an error if any assertion fails, or nil if no assertion fails.  This allows you to use the Succeed() matcher
 | ||||||
|  | // to express that a complex operation should eventually succeed.  For example:
 | ||||||
|  | //
 | ||||||
|  | //    Eventually(func() {
 | ||||||
|  | //        model, err := db.Find("foo")
 | ||||||
|  | //        Expect(err).NotTo(HaveOccurred())
 | ||||||
|  | //        Expect(model.Reticulated()).To(BeTrue())
 | ||||||
|  | //        Expect(model.Save()).To(Succeed())
 | ||||||
|  | //    }).Should(Succeed())
 | ||||||
|  | //
 | ||||||
|  | // will rerun the function until all its assertions pass.
 | ||||||
|  | //
 | ||||||
| // Eventually's default timeout is 1 second, and its default polling interval is 10ms
 | // Eventually's default timeout is 1 second, and its default polling interval is 10ms
 | ||||||
| func Eventually(actual interface{}, intervals ...interface{}) AsyncAssertion { | func Eventually(actual interface{}, intervals ...interface{}) AsyncAssertion { | ||||||
| 	return EventuallyWithOffset(0, actual, intervals...) | 	return EventuallyWithOffset(0, actual, intervals...) | ||||||
|  | @ -235,13 +290,18 @@ func EventuallyWithOffset(offset int, actual interface{}, intervals ...interface | ||||||
| // Both intervals can either be specified as time.Duration, parsable duration strings or as floats/integers.  In the
 | // Both intervals can either be specified as time.Duration, parsable duration strings or as floats/integers.  In the
 | ||||||
| // last case they are interpreted as seconds.
 | // last case they are interpreted as seconds.
 | ||||||
| //
 | //
 | ||||||
| // If Consistently is passed an actual that is a function taking no arguments and returning at least one value,
 | // If Consistently is passed an actual that is a function taking no arguments.
 | ||||||
| // then Consistently will call the function periodically and try the matcher against the function's first return value.
 | //
 | ||||||
|  | // If the function returns one value, then Consistently will call the function periodically and try the matcher against the function's first return value.
 | ||||||
| //
 | //
 | ||||||
| // If the function returns more than one value, then Consistently will pass the first value to the matcher and
 | // If the function returns more than one value, then Consistently will pass the first value to the matcher and
 | ||||||
| // assert that all other values are nil/zero.
 | // assert that all other values are nil/zero.
 | ||||||
| // This allows you to pass Consistently a function that returns a value and an error - a common pattern in Go.
 | // This allows you to pass Consistently a function that returns a value and an error - a common pattern in Go.
 | ||||||
| //
 | //
 | ||||||
|  | // Like Eventually, Consistently allows you to make assertions in the function.  If any assertion fails Consistently will fail.  In addition,
 | ||||||
|  | // Consistently also allows you to pass in a function with no return value.  In this case Consistently can be paired with the Succeed() matcher to assert
 | ||||||
|  | // that no assertions in the function fail.
 | ||||||
|  | //
 | ||||||
| // Consistently is useful in cases where you want to assert that something *does not happen* over a period of time.
 | // Consistently is useful in cases where you want to assert that something *does not happen* over a period of time.
 | ||||||
| // For example, you want to assert that a goroutine does *not* send data down a channel.  In this case, you could:
 | // For example, you want to assert that a goroutine does *not* send data down a channel.  In this case, you could:
 | ||||||
| //
 | //
 | ||||||
|  | @ -350,7 +410,7 @@ type OmegaMatcher types.GomegaMatcher | ||||||
| //
 | //
 | ||||||
| // Use `NewWithT` to instantiate a `WithT`
 | // Use `NewWithT` to instantiate a `WithT`
 | ||||||
| type WithT struct { | type WithT struct { | ||||||
| 	t types.GomegaTestingT | 	failWrapper *types.GomegaFailWrapper | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // GomegaWithT is deprecated in favor of gomega.WithT, which does not stutter.
 | // GomegaWithT is deprecated in favor of gomega.WithT, which does not stutter.
 | ||||||
|  | @ -367,7 +427,7 @@ type GomegaWithT = WithT | ||||||
| //     }
 | //     }
 | ||||||
| func NewWithT(t types.GomegaTestingT) *WithT { | func NewWithT(t types.GomegaTestingT) *WithT { | ||||||
| 	return &WithT{ | 	return &WithT{ | ||||||
| 		t: t, | 		failWrapper: testingtsupport.BuildTestingTGomegaFailWrapper(t), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -378,7 +438,7 @@ func NewGomegaWithT(t types.GomegaTestingT) *GomegaWithT { | ||||||
| 
 | 
 | ||||||
| // ExpectWithOffset is used to make assertions. See documentation for ExpectWithOffset.
 | // ExpectWithOffset is used to make assertions. See documentation for ExpectWithOffset.
 | ||||||
| func (g *WithT) ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Assertion { | func (g *WithT) ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Assertion { | ||||||
| 	return assertion.New(actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), offset, extra...) | 	return assertion.New(actual, g.failWrapper, offset, extra...) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // EventuallyWithOffset is used to make asynchronous assertions. See documentation for EventuallyWithOffset.
 | // EventuallyWithOffset is used to make asynchronous assertions. See documentation for EventuallyWithOffset.
 | ||||||
|  | @ -391,7 +451,7 @@ func (g *WithT) EventuallyWithOffset(offset int, actual interface{}, intervals . | ||||||
| 	if len(intervals) > 1 { | 	if len(intervals) > 1 { | ||||||
| 		pollingInterval = toDuration(intervals[1]) | 		pollingInterval = toDuration(intervals[1]) | ||||||
| 	} | 	} | ||||||
| 	return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, offset) | 	return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, actual, g.failWrapper, timeoutInterval, pollingInterval, offset) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ConsistentlyWithOffset is used to make asynchronous assertions. See documentation for ConsistentlyWithOffset.
 | // ConsistentlyWithOffset is used to make asynchronous assertions. See documentation for ConsistentlyWithOffset.
 | ||||||
|  | @ -404,7 +464,7 @@ func (g *WithT) ConsistentlyWithOffset(offset int, actual interface{}, intervals | ||||||
| 	if len(intervals) > 1 { | 	if len(intervals) > 1 { | ||||||
| 		pollingInterval = toDuration(intervals[1]) | 		pollingInterval = toDuration(intervals[1]) | ||||||
| 	} | 	} | ||||||
| 	return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, offset) | 	return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, g.failWrapper, timeoutInterval, pollingInterval, offset) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Expect is used to make assertions. See documentation for Expect.
 | // Expect is used to make assertions. See documentation for Expect.
 | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ import ( | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"reflect" | 	"reflect" | ||||||
|  | 	"runtime" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/onsi/gomega/internal/oraclematcher" | 	"github.com/onsi/gomega/internal/oraclematcher" | ||||||
|  | @ -31,8 +32,8 @@ type AsyncAssertion struct { | ||||||
| func New(asyncType AsyncAssertionType, actualInput interface{}, failWrapper *types.GomegaFailWrapper, timeoutInterval time.Duration, pollingInterval time.Duration, offset int) *AsyncAssertion { | func New(asyncType AsyncAssertionType, actualInput interface{}, failWrapper *types.GomegaFailWrapper, timeoutInterval time.Duration, pollingInterval time.Duration, offset int) *AsyncAssertion { | ||||||
| 	actualType := reflect.TypeOf(actualInput) | 	actualType := reflect.TypeOf(actualInput) | ||||||
| 	if actualType.Kind() == reflect.Func { | 	if actualType.Kind() == reflect.Func { | ||||||
| 		if actualType.NumIn() != 0 || actualType.NumOut() == 0 { | 		if actualType.NumIn() != 0 { | ||||||
| 			panic("Expected a function with no arguments and one or more return values.") | 			panic("Expected a function with no arguments and zero or more return values.") | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -70,13 +71,49 @@ func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interfa | ||||||
| 
 | 
 | ||||||
| func (assertion *AsyncAssertion) actualInputIsAFunction() bool { | func (assertion *AsyncAssertion) actualInputIsAFunction() bool { | ||||||
| 	actualType := reflect.TypeOf(assertion.actualInput) | 	actualType := reflect.TypeOf(assertion.actualInput) | ||||||
| 	return actualType.Kind() == reflect.Func && actualType.NumIn() == 0 && actualType.NumOut() > 0 | 	return actualType.Kind() == reflect.Func && actualType.NumIn() == 0 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (assertion *AsyncAssertion) pollActual() (interface{}, error) { | func (assertion *AsyncAssertion) pollActual() (interface{}, error) { | ||||||
| 	if assertion.actualInputIsAFunction() { | 	if !assertion.actualInputIsAFunction() { | ||||||
| 		values := reflect.ValueOf(assertion.actualInput).Call([]reflect.Value{}) | 		return assertion.actualInput, nil | ||||||
|  | 	} | ||||||
|  | 	var capturedAssertionFailure string | ||||||
|  | 	var values []reflect.Value | ||||||
| 
 | 
 | ||||||
|  | 	numOut := reflect.TypeOf(assertion.actualInput).NumOut() | ||||||
|  | 
 | ||||||
|  | 	func() { | ||||||
|  | 		originalHandler := assertion.failWrapper.Fail | ||||||
|  | 		assertion.failWrapper.Fail = func(message string, callerSkip ...int) { | ||||||
|  | 			skip := 0 | ||||||
|  | 			if len(callerSkip) > 0 { | ||||||
|  | 				skip = callerSkip[0] | ||||||
|  | 			} | ||||||
|  | 			_, file, line, _ := runtime.Caller(skip + 1) | ||||||
|  | 			capturedAssertionFailure = fmt.Sprintf("Assertion in callback at %s:%d failed:\n%s", file, line, message) | ||||||
|  | 			panic("stop execution") | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		defer func() { | ||||||
|  | 			assertion.failWrapper.Fail = originalHandler | ||||||
|  | 			if e := recover(); e != nil && capturedAssertionFailure == "" { | ||||||
|  | 				panic(e) | ||||||
|  | 			} | ||||||
|  | 		}() | ||||||
|  | 
 | ||||||
|  | 		values = reflect.ValueOf(assertion.actualInput).Call([]reflect.Value{}) | ||||||
|  | 	}() | ||||||
|  | 
 | ||||||
|  | 	if capturedAssertionFailure != "" { | ||||||
|  | 		if numOut == 0 { | ||||||
|  | 			return errors.New(capturedAssertionFailure), nil | ||||||
|  | 		} else { | ||||||
|  | 			return nil, errors.New(capturedAssertionFailure) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if numOut > 0 { | ||||||
| 		extras := []interface{}{} | 		extras := []interface{}{} | ||||||
| 		for _, value := range values[1:] { | 		for _, value := range values[1:] { | ||||||
| 			extras = append(extras, value.Interface()) | 			extras = append(extras, value.Interface()) | ||||||
|  | @ -91,7 +128,7 @@ func (assertion *AsyncAssertion) pollActual() (interface{}, error) { | ||||||
| 		return values[0].Interface(), nil | 		return values[0].Interface(), nil | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return assertion.actualInput, nil | 	return nil, nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (assertion *AsyncAssertion) matcherMayChange(matcher types.GomegaMatcher, value interface{}) bool { | func (assertion *AsyncAssertion) matcherMayChange(matcher types.GomegaMatcher, value interface{}) bool { | ||||||
|  |  | ||||||
|  | @ -482,7 +482,7 @@ github.com/onsi/ginkgo/reporters/stenographer | ||||||
| github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable | github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable | ||||||
| github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty | github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty | ||||||
| github.com/onsi/ginkgo/types | github.com/onsi/ginkgo/types | ||||||
| # github.com/onsi/gomega v1.13.0 | # github.com/onsi/gomega v1.14.0 | ||||||
| github.com/onsi/gomega | github.com/onsi/gomega | ||||||
| github.com/onsi/gomega/format | github.com/onsi/gomega/format | ||||||
| github.com/onsi/gomega/gbytes | github.com/onsi/gomega/gbytes | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue