diff --git a/src/code.cloudfoundry.org/go.mod b/src/code.cloudfoundry.org/go.mod index b564126d37..4bb02e8818 100644 --- a/src/code.cloudfoundry.org/go.mod +++ b/src/code.cloudfoundry.org/go.mod @@ -28,6 +28,8 @@ replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.2.0 replace google.golang.org/genproto => google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 +replace github.com/onsi/gomega => github.com/onsi/gomega v1.7.0 + require ( code.cloudfoundry.org/archiver v0.0.0-20210513174409-5fc719cc9491 code.cloudfoundry.org/cf-routing-test-helpers v0.0.0-20200827173955-6ac4653025b4 diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/.travis.yml b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/.travis.yml index 6543dc5539..d147e451d6 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/.travis.yml +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/.travis.yml @@ -1,18 +1,18 @@ language: go -arch: - - amd64 - - ppc64le go: + - 1.10.x + - 1.11.x + - 1.12.x - gotip - - 1.16.x - - 1.15.x env: - GO111MODULE=on -install: skip +install: + - go get -v ./... + - go build ./... + - go get github.com/onsi/ginkgo + - go install github.com/onsi/ginkgo/ginkgo -script: - - go mod tidy && git diff --exit-code go.mod go.sum - - make test +script: make test diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/CHANGELOG.md b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/CHANGELOG.md index b05f3a9357..f670740168 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/CHANGELOG.md +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/CHANGELOG.md @@ -1,90 +1,3 @@ -## 1.12.0 - -### Features -- Add Satisfy() matcher (#437) [c548f31] -- tweak truncation message [3360b8c] -- Add format.GomegaStringer (#427) [cc80b6f] -- Add Clear() method to gbytes.Buffer [c3c0920] - -### Fixes -- Fix error message in BeNumericallyMatcher (#432) [09c074a] -- Bump github.com/onsi/ginkgo from 1.12.1 to 1.16.2 (#442) [e5f6ea0] -- Bump github.com/golang/protobuf from 1.4.3 to 1.5.2 (#431) [adae3bf] -- Bump golang.org/x/net (#441) [3275b35] - -## 1.11.0 - -### Features -- feature: add index to gstruct element func (#419) [334e00d] -- feat(gexec) Add CompileTest functions. Close #410 (#411) [47c613f] - -### Fixes -- Check more carefully for nils in WithTransform (#423) [3c60a15] -- fix: typo in Makefile [b82522a] -- Allow WithTransform function to accept a nil value (#422) [b75d2f2] -- fix: print value type for interface{} containers (#409) [f08e2dc] -- fix(BeElementOf): consistently flatten expected values [1fa9468] - -## 1.10.5 - -### Fixes -- fix: collections matchers should display type of expectation (#408) [6b4eb5a] -- fix(ContainElements): consistently flatten expected values [073b880] -- fix(ConsistOf): consistently flatten expected values [7266efe] - -## 1.10.4 - -### Fixes -- update golang net library to more recent version without vulnerability (#406) [817a8b9] -- Correct spelling: alloted -> allotted (#403) [0bae715] -- fix a panic in MessageWithDiff with long message (#402) [ea06b9b] - -## 1.10.3 - -### Fixes -- updates golang/x/net to fix vulnerability detected by snyk (#394) [c479356] - -## 1.10.2 - -### Fixes -- Add ExpectWithOffset, EventuallyWithOffset and ConsistentlyWithOffset to WithT (#391) [990941a] - -## 1.10.1 - -### Fixes -- Update dependencies (#389) [9f5eecd] - -## 1.10.0 - -### Features -- Add HaveHTTPStatusMatcher (#378) [f335c94] -- Changed matcher for content-type in VerifyJSONRepresenting (#377) [6024f5b] -- Make ghttp usable with x-unit style tests (#376) [c0be499] -- Implement PanicWith matcher (#381) [f8032b4] - -## 1.9.0 - -### Features -- Add ContainElements matcher (#370) [2f57380] -- Output missing and extra elements in ConsistOf failure message [a31eda7] -- Document method LargestMatching [7c5a280] - -## 1.8.1 - -### Fixes -- Fix unexpected MatchError() behaviour (#375) [8ae7b2f] - -## 1.8.0 - -### Features -- Allow optional description to be lazily evaluated function (#364) [bf64010] -- Support wrapped errors (#359) [0a981cb] - -## 1.7.1 - -### Fixes -- Bump go-yaml version to cover fixed ddos heuristic (#362) [95e431e] - ## 1.7.0 ### Features diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/Dockerfile b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/Dockerfile deleted file mode 100644 index 11c7e63e75..0000000000 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM golang:1.15 diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/Makefile b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/Makefile index 1c6d107e17..c92cd56e3a 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/Makefile +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/Makefile @@ -1,33 +1,6 @@ -###### Help ################################################################### +test: + [ -z "`gofmt -s -w -l -e .`" ] + go vet + ginkgo -p -r --randomizeAllSpecs --failOnPending --randomizeSuites --race -.DEFAULT_GOAL = help - -.PHONY: help - -help: ## list Makefile targets - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - -###### Targets ################################################################ - -test: version download fmt vet ginkgo ## Runs all build, static analysis, and test steps - -download: ## Download dependencies - go mod download - -vet: ## Run static code analysis - go vet ./... - -ginkgo: ## Run tests using Ginkgo - go run github.com/onsi/ginkgo/ginkgo -p -r --randomizeAllSpecs --failOnPending --randomizeSuites --race - -fmt: ## Checks that the code is formatted correcty - @@if [ -n "$$(gofmt -s -e -l -d .)" ]; then \ - echo "gofmt check failed: run 'gofmt -s -e -l -w .'"; \ - exit 1; \ - fi - -docker_test: ## Run tests in a container via docker-compose - docker-compose build test && docker-compose run --rm test make test - -version: ## Display the version of Go - @@go version +.PHONY: test diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/docker-compose.yaml b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/docker-compose.yaml deleted file mode 100644 index f37496143d..0000000000 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/docker-compose.yaml +++ /dev/null @@ -1,10 +0,0 @@ -version: '3.0' - -services: - test: - build: - dockerfile: Dockerfile - context: . - working_dir: /app - volumes: - - ${PWD}:/app diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/format/format.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/format/format.go index 6e78c391df..fae25adceb 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/format/format.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/format/format.go @@ -7,7 +7,6 @@ Gomega's format package pretty-prints objects. It explores input objects recurs package format import ( - "context" "fmt" "reflect" "strconv" @@ -18,10 +17,6 @@ import ( // Use MaxDepth to set the maximum recursion depth when printing deeply nested objects var MaxDepth = uint(10) -// MaxLength of the string representation of an object. -// If MaxLength is set to 0, the Object will not be truncated. -var MaxLength = 4000 - /* By default, all objects (even those that implement fmt.Stringer and fmt.GoStringer) are recursively inspected to generate output. @@ -49,7 +44,16 @@ var TruncateThreshold uint = 50 // after the first diff location in a truncated string assertion error message. var CharactersAroundMismatchToInclude uint = 5 -var contextType = reflect.TypeOf((*context.Context)(nil)).Elem() +// Ctx interface defined here to keep backwards compatibility with go < 1.7 +// It matches the context.Context interface +type Ctx interface { + Deadline() (deadline time.Time, ok bool) + Done() <-chan struct{} + Err() error + Value(key interface{}) interface{} +} + +var contextType = reflect.TypeOf((*Ctx)(nil)).Elem() var timeType = reflect.TypeOf(time.Time{}) //The default indentation string emitted by the format package @@ -57,14 +61,6 @@ var Indent = " " var longFormThreshold = 20 -// GomegaStringer allows for custom formating of objects for gomega. -type GomegaStringer interface { - // GomegaString will be used to custom format an object. - // It does not follow UseStringerRepresentation value and will always be called regardless. - // It also ignores the MaxLength value. - GomegaString() string -} - /* Generates a formatted matcher success/failure message of the form: @@ -109,13 +105,7 @@ func MessageWithDiff(actual, message, expected string) string { tabLength := 4 spaceFromMessageToActual := tabLength + len(": ") - len(message) - - paddingCount := spaceFromMessageToActual + spacesBeforeFormattedMismatch - if paddingCount < 0 { - return Message(formattedActual, message, formattedExpected) - } - - padding := strings.Repeat(" ", paddingCount) + "|" + padding := strings.Repeat(" ", spaceFromMessageToActual+spacesBeforeFormattedMismatch) + "|" return Message(formattedActual, message+padding, formattedExpected) } @@ -171,33 +161,6 @@ func findFirstMismatch(a, b string) int { return 0 } -const truncateHelpText = ` -Gomega truncated this representation as it exceeds 'format.MaxLength'. -Consider having the object provide a custom 'GomegaStringer' representation -or adjust the parameters in Gomega's 'format' package. - -Learn more here: https://onsi.github.io/gomega/#adjusting-output -` - -func truncateLongStrings(s string) string { - if MaxLength > 0 && len(s) > MaxLength { - var sb strings.Builder - for i, r := range s { - if i < MaxLength { - sb.WriteRune(r) - continue - } - break - } - - sb.WriteString("...\n") - sb.WriteString(truncateHelpText) - - return sb.String() - } - return s -} - /* Pretty prints the passed in object at the passed in indentation level. @@ -212,7 +175,7 @@ Set PrintContextObjects to true to print the content of objects implementing con func Object(object interface{}, indentation uint) string { indent := strings.Repeat(Indent, int(indentation)) value := reflect.ValueOf(object) - return fmt.Sprintf("%s<%s>: %s", indent, formatType(value), formatValue(value, indentation)) + return fmt.Sprintf("%s<%s>: %s", indent, formatType(object), formatValue(value, indentation)) } /* @@ -232,20 +195,25 @@ func IndentString(s string, indentation uint) string { return result } -func formatType(v reflect.Value) string { - switch v.Kind() { - case reflect.Invalid: +func formatType(object interface{}) string { + t := reflect.TypeOf(object) + if t == nil { return "nil" + } + switch t.Kind() { case reflect.Chan: - return fmt.Sprintf("%s | len:%d, cap:%d", v.Type(), v.Len(), v.Cap()) + v := reflect.ValueOf(object) + return fmt.Sprintf("%T | len:%d, cap:%d", object, v.Len(), v.Cap()) case reflect.Ptr: - return fmt.Sprintf("%s | 0x%x", v.Type(), v.Pointer()) + return fmt.Sprintf("%T | %p", object, object) case reflect.Slice: - return fmt.Sprintf("%s | len:%d, cap:%d", v.Type(), v.Len(), v.Cap()) + v := reflect.ValueOf(object) + return fmt.Sprintf("%T | len:%d, cap:%d", object, v.Len(), v.Cap()) case reflect.Map: - return fmt.Sprintf("%s | len:%d", v.Type(), v.Len()) + v := reflect.ValueOf(object) + return fmt.Sprintf("%T | len:%d", object, v.Len()) default: - return fmt.Sprintf("%s", v.Type()) + return fmt.Sprintf("%T", object) } } @@ -258,21 +226,14 @@ func formatValue(value reflect.Value, indentation uint) string { return "nil" } - if value.CanInterface() { - obj := value.Interface() - - // GomegaStringer will take precedence to other representations and disregards UseStringerRepresentation - if x, ok := obj.(GomegaStringer); ok { - // do not truncate a user-defined GoMegaString() value - return x.GomegaString() - } - - if UseStringerRepresentation { + if UseStringerRepresentation { + if value.CanInterface() { + obj := value.Interface() switch x := obj.(type) { case fmt.GoStringer: - return truncateLongStrings(x.GoString()) + return x.GoString() case fmt.Stringer: - return truncateLongStrings(x.String()) + return x.String() } } } @@ -303,26 +264,26 @@ func formatValue(value reflect.Value, indentation uint) string { case reflect.Ptr: return formatValue(value.Elem(), indentation) case reflect.Slice: - return truncateLongStrings(formatSlice(value, indentation)) + return formatSlice(value, indentation) case reflect.String: - return truncateLongStrings(formatString(value.String(), indentation)) + return formatString(value.String(), indentation) case reflect.Array: - return truncateLongStrings(formatSlice(value, indentation)) + return formatSlice(value, indentation) case reflect.Map: - return truncateLongStrings(formatMap(value, indentation)) + return formatMap(value, indentation) case reflect.Struct: if value.Type() == timeType && value.CanInterface() { t, _ := value.Interface().(time.Time) return t.Format(time.RFC3339Nano) } - return truncateLongStrings(formatStruct(value, indentation)) + return formatStruct(value, indentation) case reflect.Interface: - return formatInterface(value, indentation) + return formatValue(value.Elem(), indentation) default: if value.CanInterface() { - return truncateLongStrings(fmt.Sprintf("%#v", value.Interface())) + return fmt.Sprintf("%#v", value.Interface()) } - return truncateLongStrings(fmt.Sprintf("%#v", value)) + return fmt.Sprintf("%#v", value) } } @@ -412,10 +373,6 @@ func formatStruct(v reflect.Value, indentation uint) string { return fmt.Sprintf("{%s}", strings.Join(result, ", ")) } -func formatInterface(v reflect.Value, indentation uint) string { - return fmt.Sprintf("<%s>%s", formatType(v.Elem()), formatValue(v.Elem(), indentation)) -} - func isNilValue(a reflect.Value) bool { switch a.Kind() { case reflect.Invalid: diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/buffer.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/buffer.go index 809f3c5430..336086f4aa 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/buffer.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/buffer.go @@ -108,22 +108,6 @@ func (b *Buffer) Read(d []byte) (int, error) { return n, nil } -/* -Clear clears out the buffer's contents -*/ -func (b *Buffer) Clear() error { - b.lock.Lock() - defer b.lock.Unlock() - - if b.closed { - return errors.New("attempt to clear closed buffer") - } - - b.contents = []byte{} - b.readCursor = 0 - return nil -} - /* Close signifies that the buffer will no longer be written to */ diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/io_wrappers.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/io_wrappers.go index a41ad6232f..3caed87693 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/io_wrappers.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gbytes/io_wrappers.go @@ -9,17 +9,17 @@ import ( // ErrTimeout is returned by TimeoutCloser, TimeoutReader, and TimeoutWriter when the underlying Closer/Reader/Writer does not return within the specified timeout var ErrTimeout = errors.New("timeout occurred") -// TimeoutCloser returns an io.Closer that wraps the passed-in io.Closer. If the underlying Closer fails to close within the allotted timeout ErrTimeout is returned. +// TimeoutCloser returns an io.Closer that wraps the passed-in io.Closer. If the underlying Closer fails to close within the alloted timeout ErrTimeout is returned. func TimeoutCloser(c io.Closer, timeout time.Duration) io.Closer { return timeoutReaderWriterCloser{c: c, d: timeout} } -// TimeoutReader returns an io.Reader that wraps the passed-in io.Reader. If the underlying Reader fails to read within the allotted timeout ErrTimeout is returned. +// TimeoutReader returns an io.Reader that wraps the passed-in io.Reader. If the underlying Reader fails to read within the alloted timeout ErrTimeout is returned. func TimeoutReader(r io.Reader, timeout time.Duration) io.Reader { return timeoutReaderWriterCloser{r: r, d: timeout} } -// TimeoutWriter returns an io.Writer that wraps the passed-in io.Writer. If the underlying Writer fails to write within the allotted timeout ErrTimeout is returned. +// TimeoutWriter returns an io.Writer that wraps the passed-in io.Writer. If the underlying Writer fails to write within the alloted timeout ErrTimeout is returned. func TimeoutWriter(w io.Writer, timeout time.Duration) io.Writer { return timeoutReaderWriterCloser{w: w, d: timeout} } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gexec/build.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gexec/build.go index c7aba62b7e..741d845f40 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gexec/build.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gexec/build.go @@ -3,8 +3,6 @@ package gexec import ( - "crypto/md5" - "encoding/hex" "errors" "fmt" "go/build" @@ -48,135 +46,6 @@ func BuildIn(gopath string, packagePath string, args ...string) (compiledPath st return doBuild(gopath, packagePath, nil, args...) } -func doBuild(gopath, packagePath string, env []string, args ...string) (compiledPath string, err error) { - executable, err := newExecutablePath(gopath, packagePath) - if err != nil { - return "", err - } - - cmdArgs := append([]string{"build"}, args...) - cmdArgs = append(cmdArgs, "-o", executable, packagePath) - - build := exec.Command("go", cmdArgs...) - build.Env = replaceGoPath(os.Environ(), gopath) - build.Env = append(build.Env, env...) - - output, err := build.CombinedOutput() - if err != nil { - return "", fmt.Errorf("Failed to build %s:\n\nError:\n%s\n\nOutput:\n%s", packagePath, err, string(output)) - } - - return executable, nil -} - -/* -CompileTest uses go test to compile the test package at packagePath. The resulting binary is saved off in a temporary directory. -A path pointing to this binary is returned. - -CompileTest uses the $GOPATH set in your environment. If $GOPATH is not set and you are using Go 1.8+, -it will use the default GOPATH instead. It passes the variadic args on to `go test`. -*/ -func CompileTest(packagePath string, args ...string) (compiledPath string, err error) { - return doCompileTest(build.Default.GOPATH, packagePath, nil, args...) -} - -/* -GetAndCompileTest is identical to CompileTest but `go get` the package before compiling tests. -*/ -func GetAndCompileTest(packagePath string, args ...string) (compiledPath string, err error) { - if err := getForTest(build.Default.GOPATH, packagePath, nil); err != nil { - return "", err - } - - return doCompileTest(build.Default.GOPATH, packagePath, nil, args...) -} - -/* -CompileTestWithEnvironment is identical to CompileTest but allows you to specify env vars to be set at build time. -*/ -func CompileTestWithEnvironment(packagePath string, env []string, args ...string) (compiledPath string, err error) { - return doCompileTest(build.Default.GOPATH, packagePath, env, args...) -} - -/* -GetAndCompileTestWithEnvironment is identical to GetAndCompileTest but allows you to specify env vars to be set at build time. -*/ -func GetAndCompileTestWithEnvironment(packagePath string, env []string, args ...string) (compiledPath string, err error) { - if err := getForTest(build.Default.GOPATH, packagePath, env); err != nil { - return "", err - } - - return doCompileTest(build.Default.GOPATH, packagePath, env, args...) -} - -/* -CompileTestIn is identical to CompileTest but allows you to specify a custom $GOPATH (the first argument). -*/ -func CompileTestIn(gopath string, packagePath string, args ...string) (compiledPath string, err error) { - return doCompileTest(gopath, packagePath, nil, args...) -} - -/* -GetAndCompileTestIn is identical to GetAndCompileTest but allows you to specify a custom $GOPATH (the first argument). -*/ -func GetAndCompileTestIn(gopath string, packagePath string, args ...string) (compiledPath string, err error) { - if err := getForTest(gopath, packagePath, nil); err != nil { - return "", err - } - - return doCompileTest(gopath, packagePath, nil, args...) -} - -func isLocalPackage(packagePath string) bool { - return strings.HasPrefix(packagePath, ".") -} - -func getForTest(gopath, packagePath string, env []string) error { - if isLocalPackage(packagePath) { - return nil - } - - return doGet(gopath, packagePath, env, "-t") -} - -func doGet(gopath, packagePath string, env []string, args ...string) error { - args = append(args, packagePath) - args = append([]string{"get"}, args...) - - goGet := exec.Command("go", args...) - goGet.Dir = gopath - goGet.Env = replaceGoPath(os.Environ(), gopath) - goGet.Env = append(goGet.Env, env...) - - output, err := goGet.CombinedOutput() - if err != nil { - return fmt.Errorf("Failed to get %s:\n\nError:\n%s\n\nOutput:\n%s", packagePath, err, string(output)) - } - - return nil -} - -func doCompileTest(gopath, packagePath string, env []string, args ...string) (compiledPath string, err error) { - executable, err := newExecutablePath(gopath, packagePath, ".test") - if err != nil { - return "", err - } - - cmdArgs := append([]string{"test", "-c"}, args...) - cmdArgs = append(cmdArgs, "-o", executable, packagePath) - - build := exec.Command("go", cmdArgs...) - build.Env = replaceGoPath(os.Environ(), gopath) - build.Env = append(build.Env, env...) - - output, err := build.CombinedOutput() - if err != nil { - return "", fmt.Errorf("Failed to build %s:\n\nError:\n%s\n\nOutput:\n%s", packagePath, err, string(output)) - } - - return executable, nil -} - func replaceGoPath(environ []string, newGoPath string) []string { newEnviron := []string{} for _, v := range environ { @@ -187,7 +56,7 @@ func replaceGoPath(environ []string, newGoPath string) []string { return append(newEnviron, "GOPATH="+newGoPath) } -func newExecutablePath(gopath, packagePath string, suffixes ...string) (string, error) { +func doBuild(gopath, packagePath string, env []string, args ...string) (compiledPath string, err error) { tmpDir, err := temporaryDirectory() if err != nil { return "", err @@ -197,14 +66,23 @@ func newExecutablePath(gopath, packagePath string, suffixes ...string) (string, return "", errors.New("$GOPATH not provided when building " + packagePath) } - hash := md5.Sum([]byte(packagePath)) - filename := fmt.Sprintf("%s-%x%s", path.Base(packagePath), hex.EncodeToString(hash[:]), strings.Join(suffixes, "")) - executable := filepath.Join(tmpDir, filename) - + executable := filepath.Join(tmpDir, path.Base(packagePath)) if runtime.GOOS == "windows" { executable += ".exe" } + cmdArgs := append([]string{"build"}, args...) + cmdArgs = append(cmdArgs, "-o", executable, packagePath) + + build := exec.Command("go", cmdArgs...) + build.Env = replaceGoPath(os.Environ(), gopath) + build.Env = append(build.Env, env...) + + output, err := build.CombinedOutput() + if err != nil { + return "", fmt.Errorf("Failed to build %s:\n\nError:\n%s\n\nOutput:\n%s", packagePath, err, string(output)) + } + return executable, nil } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/handlers.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/handlers.go index efb96a25e5..64e612bdb8 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/handlers.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/handlers.go @@ -13,21 +13,10 @@ import ( "strings" "github.com/golang/protobuf/proto" - "github.com/onsi/gomega" . "github.com/onsi/gomega" "github.com/onsi/gomega/types" ) -type GHTTPWithGomega struct { - gomega Gomega -} - -func NewGHTTPWithGomega(gomega Gomega) *GHTTPWithGomega { - return &GHTTPWithGomega{ - gomega: gomega, - } -} - //CombineHandler takes variadic list of handlers and produces one handler //that calls each handler in order. func CombineHandlers(handlers ...http.HandlerFunc) http.HandlerFunc { @@ -43,51 +32,51 @@ func CombineHandlers(handlers ...http.HandlerFunc) http.HandlerFunc { // //For path, you may pass in a string, in which case strict equality will be applied //Alternatively you can pass in a matcher (ContainSubstring("/foo") and MatchRegexp("/foo/[a-f0-9]+") for example) -func (g GHTTPWithGomega) VerifyRequest(method string, path interface{}, rawQuery ...string) http.HandlerFunc { +func VerifyRequest(method string, path interface{}, rawQuery ...string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { - g.gomega.Expect(req.Method).Should(Equal(method), "Method mismatch") + Expect(req.Method).Should(Equal(method), "Method mismatch") switch p := path.(type) { case types.GomegaMatcher: - g.gomega.Expect(req.URL.Path).Should(p, "Path mismatch") + Expect(req.URL.Path).Should(p, "Path mismatch") default: - g.gomega.Expect(req.URL.Path).Should(Equal(path), "Path mismatch") + Expect(req.URL.Path).Should(Equal(path), "Path mismatch") } if len(rawQuery) > 0 { values, err := url.ParseQuery(rawQuery[0]) - g.gomega.Expect(err).ShouldNot(HaveOccurred(), "Expected RawQuery is malformed") + Expect(err).ShouldNot(HaveOccurred(), "Expected RawQuery is malformed") - g.gomega.Expect(req.URL.Query()).Should(Equal(values), "RawQuery mismatch") + Expect(req.URL.Query()).Should(Equal(values), "RawQuery mismatch") } } } //VerifyContentType returns a handler that verifies that a request has a Content-Type header set to the //specified value -func (g GHTTPWithGomega) VerifyContentType(contentType string) http.HandlerFunc { +func VerifyContentType(contentType string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { - g.gomega.Expect(req.Header.Get("Content-Type")).Should(Equal(contentType)) + Expect(req.Header.Get("Content-Type")).Should(Equal(contentType)) } } //VerifyMimeType returns a handler that verifies that a request has a specified mime type set //in Content-Type header -func (g GHTTPWithGomega) VerifyMimeType(mimeType string) http.HandlerFunc { +func VerifyMimeType(mimeType string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { - g.gomega.Expect(strings.Split(req.Header.Get("Content-Type"), ";")[0]).Should(Equal(mimeType)) + Expect(strings.Split(req.Header.Get("Content-Type"), ";")[0]).Should(Equal(mimeType)) } } //VerifyBasicAuth returns a handler that verifies the request contains a BasicAuth Authorization header //matching the passed in username and password -func (g GHTTPWithGomega) VerifyBasicAuth(username string, password string) http.HandlerFunc { +func VerifyBasicAuth(username string, password string) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { auth := req.Header.Get("Authorization") - g.gomega.Expect(auth).ShouldNot(Equal(""), "Authorization header must be specified") + Expect(auth).ShouldNot(Equal(""), "Authorization header must be specified") decoded, err := base64.StdEncoding.DecodeString(auth[6:]) - g.gomega.Expect(err).ShouldNot(HaveOccurred()) + Expect(err).ShouldNot(HaveOccurred()) - g.gomega.Expect(string(decoded)).Should(Equal(fmt.Sprintf("%s:%s", username, password)), "Authorization mismatch") + Expect(string(decoded)).Should(Equal(fmt.Sprintf("%s:%s", username, password)), "Authorization mismatch") } } @@ -96,11 +85,11 @@ func (g GHTTPWithGomega) VerifyBasicAuth(username string, password string) http. // //The request must contain *all* the passed in headers, but it is allowed to have additional headers //beyond the passed in set. -func (g GHTTPWithGomega) VerifyHeader(header http.Header) http.HandlerFunc { +func VerifyHeader(header http.Header) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { for key, values := range header { key = http.CanonicalHeaderKey(key) - g.gomega.Expect(req.Header[key]).Should(Equal(values), "Header mismatch for key: %s", key) + Expect(req.Header[key]).Should(Equal(values), "Header mismatch for key: %s", key) } } } @@ -108,19 +97,19 @@ func (g GHTTPWithGomega) VerifyHeader(header http.Header) http.HandlerFunc { //VerifyHeaderKV returns a handler that verifies the request contains a header matching the passed in key and values //(recall that a `http.Header` is a mapping from string (key) to []string (values)) //It is a convenience wrapper around `VerifyHeader` that allows you to avoid having to create an `http.Header` object. -func (g GHTTPWithGomega) VerifyHeaderKV(key string, values ...string) http.HandlerFunc { +func VerifyHeaderKV(key string, values ...string) http.HandlerFunc { return VerifyHeader(http.Header{key: values}) } //VerifyBody returns a handler that verifies that the body of the request matches the passed in byte array. //It does this using Equal(). -func (g GHTTPWithGomega) VerifyBody(expectedBody []byte) http.HandlerFunc { +func VerifyBody(expectedBody []byte) http.HandlerFunc { return CombineHandlers( func(w http.ResponseWriter, req *http.Request) { body, err := ioutil.ReadAll(req.Body) req.Body.Close() - g.gomega.Expect(err).ShouldNot(HaveOccurred()) - g.gomega.Expect(body).Should(Equal(expectedBody), "Body Mismatch") + Expect(err).ShouldNot(HaveOccurred()) + Expect(body).Should(Equal(expectedBody), "Body Mismatch") }, ) } @@ -129,14 +118,14 @@ func (g GHTTPWithGomega) VerifyBody(expectedBody []byte) http.HandlerFunc { //matching the passed in JSON string. It does this using Gomega's MatchJSON method // //VerifyJSON also verifies that the request's content type is application/json -func (g GHTTPWithGomega) VerifyJSON(expectedJSON string) http.HandlerFunc { +func VerifyJSON(expectedJSON string) http.HandlerFunc { return CombineHandlers( VerifyMimeType("application/json"), func(w http.ResponseWriter, req *http.Request) { body, err := ioutil.ReadAll(req.Body) req.Body.Close() - g.gomega.Expect(err).ShouldNot(HaveOccurred()) - g.gomega.Expect(body).Should(MatchJSON(expectedJSON), "JSON Mismatch") + Expect(err).ShouldNot(HaveOccurred()) + Expect(body).Should(MatchJSON(expectedJSON), "JSON Mismatch") }, ) } @@ -144,11 +133,11 @@ func (g GHTTPWithGomega) VerifyJSON(expectedJSON string) http.HandlerFunc { //VerifyJSONRepresenting is similar to VerifyJSON. Instead of taking a JSON string, however, it //takes an arbitrary JSON-encodable object and verifies that the requests's body is a JSON representation //that matches the object -func (g GHTTPWithGomega) VerifyJSONRepresenting(object interface{}) http.HandlerFunc { +func VerifyJSONRepresenting(object interface{}) http.HandlerFunc { data, err := json.Marshal(object) - g.gomega.Expect(err).ShouldNot(HaveOccurred()) + Expect(err).ShouldNot(HaveOccurred()) return CombineHandlers( - VerifyMimeType("application/json"), + VerifyContentType("application/json"), VerifyJSON(string(data)), ) } @@ -157,12 +146,12 @@ func (g GHTTPWithGomega) VerifyJSONRepresenting(object interface{}) http.Handler // //The request must contain *all* of the specified values, but it is allowed to have additional //form values beyond the passed in set. -func (g GHTTPWithGomega) VerifyForm(values url.Values) http.HandlerFunc { +func VerifyForm(values url.Values) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() - g.gomega.Expect(err).ShouldNot(HaveOccurred()) + Expect(err).ShouldNot(HaveOccurred()) for key, vals := range values { - g.gomega.Expect(r.Form[key]).Should(Equal(vals), "Form mismatch for key: %s", key) + Expect(r.Form[key]).Should(Equal(vals), "Form mismatch for key: %s", key) } } } @@ -170,7 +159,7 @@ func (g GHTTPWithGomega) VerifyForm(values url.Values) http.HandlerFunc { //VerifyFormKV returns a handler that verifies a request contains a form key with the specified values. // //It is a convenience wrapper around `VerifyForm` that lets you avoid having to create a `url.Values` object. -func (g GHTTPWithGomega) VerifyFormKV(key string, values ...string) http.HandlerFunc { +func VerifyFormKV(key string, values ...string) http.HandlerFunc { return VerifyForm(url.Values{key: values}) } @@ -178,24 +167,24 @@ func (g GHTTPWithGomega) VerifyFormKV(key string, values ...string) http.Handler //representation of the passed message. // //VerifyProtoRepresenting also verifies that the request's content type is application/x-protobuf -func (g GHTTPWithGomega) VerifyProtoRepresenting(expected proto.Message) http.HandlerFunc { +func VerifyProtoRepresenting(expected proto.Message) http.HandlerFunc { return CombineHandlers( VerifyContentType("application/x-protobuf"), func(w http.ResponseWriter, req *http.Request) { body, err := ioutil.ReadAll(req.Body) - g.gomega.Expect(err).ShouldNot(HaveOccurred()) + Expect(err).ShouldNot(HaveOccurred()) req.Body.Close() expectedType := reflect.TypeOf(expected) actualValuePtr := reflect.New(expectedType.Elem()) actual, ok := actualValuePtr.Interface().(proto.Message) - g.gomega.Expect(ok).Should(BeTrue(), "Message value is not a proto.Message") + Expect(ok).Should(BeTrue(), "Message value is not a proto.Message") err = proto.Unmarshal(body, actual) - g.gomega.Expect(err).ShouldNot(HaveOccurred(), "Failed to unmarshal protobuf") + Expect(err).ShouldNot(HaveOccurred(), "Failed to unmarshal protobuf") - g.gomega.Expect(actual).Should(Equal(expected), "ProtoBuf Mismatch") + Expect(actual).Should(Equal(expected), "ProtoBuf Mismatch") }, ) } @@ -213,7 +202,7 @@ Body may be a string or []byte Also, RespondWith can be given an optional http.Header. The headers defined therein will be added to the response headers. */ -func (g GHTTPWithGomega) RespondWith(statusCode int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { +func RespondWith(statusCode int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { if len(optionalHeader) == 1 { copyHeader(optionalHeader[0], w.Header()) @@ -225,7 +214,7 @@ func (g GHTTPWithGomega) RespondWith(statusCode int, body interface{}, optionalH case []byte: w.Write(x) default: - g.gomega.Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.") + Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.") } } } @@ -239,7 +228,7 @@ to share the same setup but specify different status codes and bodies. Also, RespondWithPtr can be given an optional http.Header. The headers defined therein will be added to the response headers. Since the http.Header can be mutated after the fact you don't need to pass in a pointer. */ -func (g GHTTPWithGomega) RespondWithPtr(statusCode *int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { +func RespondWithPtr(statusCode *int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { if len(optionalHeader) == 1 { copyHeader(optionalHeader[0], w.Header()) @@ -252,7 +241,7 @@ func (g GHTTPWithGomega) RespondWithPtr(statusCode *int, body interface{}, optio case *[]byte: w.Write(*x) default: - g.gomega.Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.") + Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.") } } } @@ -264,9 +253,9 @@ containing the JSON-encoding of the passed in object Also, RespondWithJSONEncoded can be given an optional http.Header. The headers defined therein will be added to the response headers. */ -func (g GHTTPWithGomega) RespondWithJSONEncoded(statusCode int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { +func RespondWithJSONEncoded(statusCode int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { data, err := json.Marshal(object) - g.gomega.Expect(err).ShouldNot(HaveOccurred()) + Expect(err).ShouldNot(HaveOccurred()) var headers http.Header if len(optionalHeader) == 1 { @@ -290,10 +279,10 @@ objects. Also, RespondWithJSONEncodedPtr can be given an optional http.Header. The headers defined therein will be added to the response headers. Since the http.Header can be mutated after the fact you don't need to pass in a pointer. */ -func (g GHTTPWithGomega) RespondWithJSONEncodedPtr(statusCode *int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { +func RespondWithJSONEncodedPtr(statusCode *int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { data, err := json.Marshal(object) - g.gomega.Expect(err).ShouldNot(HaveOccurred()) + Expect(err).ShouldNot(HaveOccurred()) var headers http.Header if len(optionalHeader) == 1 { headers = optionalHeader[0] @@ -313,10 +302,10 @@ func (g GHTTPWithGomega) RespondWithJSONEncodedPtr(statusCode *int, object inter //containing the protobuf serialization of the provided message. // //Also, RespondWithProto can be given an optional http.Header. The headers defined therein will be added to the response headers. -func (g GHTTPWithGomega) RespondWithProto(statusCode int, message proto.Message, optionalHeader ...http.Header) http.HandlerFunc { +func RespondWithProto(statusCode int, message proto.Message, optionalHeader ...http.Header) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { data, err := proto.Marshal(message) - g.gomega.Expect(err).ShouldNot(HaveOccurred()) + Expect(err).ShouldNot(HaveOccurred()) var headers http.Header if len(optionalHeader) == 1 { @@ -333,71 +322,3 @@ func (g GHTTPWithGomega) RespondWithProto(statusCode int, message proto.Message, w.Write(data) } } - -func VerifyRequest(method string, path interface{}, rawQuery ...string) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyRequest(method, path, rawQuery...) -} - -func VerifyContentType(contentType string) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyContentType(contentType) -} - -func VerifyMimeType(mimeType string) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyMimeType(mimeType) -} - -func VerifyBasicAuth(username string, password string) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyBasicAuth(username, password) -} - -func VerifyHeader(header http.Header) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyHeader(header) -} - -func VerifyHeaderKV(key string, values ...string) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyHeaderKV(key, values...) -} - -func VerifyBody(expectedBody []byte) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyBody(expectedBody) -} - -func VerifyJSON(expectedJSON string) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyJSON(expectedJSON) -} - -func VerifyJSONRepresenting(object interface{}) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyJSONRepresenting(object) -} - -func VerifyForm(values url.Values) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyForm(values) -} - -func VerifyFormKV(key string, values ...string) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyFormKV(key, values...) -} - -func VerifyProtoRepresenting(expected proto.Message) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).VerifyProtoRepresenting(expected) -} - -func RespondWith(statusCode int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).RespondWith(statusCode, body, optionalHeader...) -} - -func RespondWithPtr(statusCode *int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).RespondWithPtr(statusCode, body, optionalHeader...) -} - -func RespondWithJSONEncoded(statusCode int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).RespondWithJSONEncoded(statusCode, object, optionalHeader...) -} - -func RespondWithJSONEncodedPtr(statusCode *int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).RespondWithJSONEncodedPtr(statusCode, object, optionalHeader...) -} - -func RespondWithProto(statusCode int, message proto.Message, optionalHeader ...http.Header) http.HandlerFunc { - return NewGHTTPWithGomega(gomega.Default).RespondWithProto(statusCode, message, optionalHeader...) -} diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/test_server.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/test_server.go index a9d2f8fef3..057d3ba4e0 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/test_server.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/ghttp/test_server.go @@ -37,8 +37,8 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes )) }) - When("requesting all sprockets", func() { - When("the response is successful", func() { + Context("when requesting all sprockets", func() { + Context("when the response is successful", func() { BeforeEach(func() { sprockets = []Sprocket{ NewSprocket("Alfalfa"), @@ -51,7 +51,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes }) }) - When("the response is missing", func() { + Context("when the response is missing", func() { BeforeEach(func() { statusCode = http.StatusNotFound }) @@ -61,7 +61,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes }) }) - When("the response fails to authenticate", func() { + Context("when the response fails to authenticate", func() { BeforeEach(func() { statusCode = http.StatusUnauthorized }) @@ -73,7 +73,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes }) }) - When("the response is a server failure", func() { + Context("when the response is a server failure", func() { BeforeEach(func() { statusCode = http.StatusInternalServerError }) @@ -86,7 +86,7 @@ A more comprehensive example is available at https://onsi.github.io/gomega/#_tes }) }) - When("requesting some sprockets", func() { + Context("when requesting some sprockets", func() { BeforeEach(func() { sprockets = []Sprocket{ NewSprocket("Alfalfa"), diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.mod b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.mod index f74d9ea108..65eedf6967 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.mod +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.mod @@ -1,10 +1,15 @@ module github.com/onsi/gomega -go 1.14 - require ( - github.com/golang/protobuf v1.5.2 - github.com/onsi/ginkgo v1.16.2 - golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 - gopkg.in/yaml.v2 v2.4.0 + github.com/fsnotify/fsnotify v1.4.7 // indirect + github.com/golang/protobuf v1.2.0 + github.com/hpcloud/tail v1.0.0 // indirect + github.com/onsi/ginkgo v1.6.0 + golang.org/x/net v0.0.0-20180906233101-161cd47e91fd + golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect + golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e // indirect + golang.org/x/text v0.3.0 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.2.1 ) diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.sum b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.sum index 1ae731a5cd..b23f6ef028 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.sum +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/go.sum @@ -1,93 +1,24 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 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/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -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 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= 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.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= 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.16.2 h1:HFB2fbVIlhIfCfOW81bZFbiC/RvnpXSdhbF2/DJr134= -github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= -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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -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/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-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-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -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.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gomega_dsl.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gomega_dsl.go index 9050e15e8f..b145768cf2 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gomega_dsl.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gomega_dsl.go @@ -24,7 +24,7 @@ import ( "github.com/onsi/gomega/types" ) -const GOMEGA_VERSION = "1.12.0" +const GOMEGA_VERSION = "1.7.0" 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(). @@ -252,7 +252,7 @@ func Consistently(actual interface{}, intervals ...interface{}) AsyncAssertion { return ConsistentlyWithOffset(0, actual, intervals...) } -// ConsistentlyWithOffset operates like Consistently but takes an additional +// ConsistentlyWithOffset operates like Consistnetly but takes an additional // initial argument to indicate an offset in the call stack. This is useful when building helper // functions that contain matchers. To learn more, read about `ExpectWithOffset`. func ConsistentlyWithOffset(offset int, actual interface{}, intervals ...interface{}) AsyncAssertion { @@ -293,18 +293,16 @@ func SetDefaultConsistentlyPollingInterval(t time.Duration) { // AsyncAssertion is returned by Eventually and Consistently and polls the actual value passed into Eventually against // the matcher passed to the Should and ShouldNot methods. // -// Both Should and ShouldNot take a variadic optionalDescription argument. -// This argument allows you to make your failure messages more descriptive. -// If a single argument of type `func() string` is passed, this function will be lazily evaluated if a failure occurs -// and the returned string is used to annotate the failure message. -// Otherwise, this argument is passed on to fmt.Sprintf() and then used to annotate the failure message. +// Both Should and ShouldNot take a variadic optionalDescription argument. This is passed on to +// fmt.Sprintf() and is used to annotate failure messages. This allows you to make your failure messages more +// descriptive. // // Both Should and ShouldNot return a boolean that is true if the assertion passed and false if it failed. // // Example: // // Eventually(myChannel).Should(Receive(), "Something should have come down the pipe.") -// Consistently(myChannel).ShouldNot(Receive(), func() string { return "Nothing should have come down the pipe." }) +// Consistently(myChannel).ShouldNot(Receive(), "Nothing should have come down the pipe.") type AsyncAssertion interface { Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool @@ -319,11 +317,8 @@ type GomegaAsyncAssertion = AsyncAssertion // Typically Should/ShouldNot are used with Ω and To/ToNot/NotTo are used with Expect // though this is not enforced. // -// All methods take a variadic optionalDescription argument. -// This argument allows you to make your failure messages more descriptive. -// If a single argument of type `func() string` is passed, this function will be lazily evaluated if a failure occurs -// and the returned string is used to annotate the failure message. -// Otherwise, this argument is passed on to fmt.Sprintf() and then used to annotate the failure message. +// All methods take a variadic optionalDescription argument. This is passed on to fmt.Sprintf() +// and is used to annotate failure messages. // // All methods return a bool that is true if the assertion passed and false if it failed. // @@ -376,13 +371,13 @@ func NewGomegaWithT(t types.GomegaTestingT) *GomegaWithT { return NewWithT(t) } -// ExpectWithOffset is used to make assertions. See documentation for ExpectWithOffset. -func (g *WithT) ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Assertion { - return assertion.New(actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), offset, extra...) +// Expect is used to make assertions. See documentation for Expect. +func (g *WithT) Expect(actual interface{}, extra ...interface{}) Assertion { + return assertion.New(actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), 0, extra...) } -// EventuallyWithOffset is used to make asynchronous assertions. See documentation for EventuallyWithOffset. -func (g *WithT) EventuallyWithOffset(offset int, actual interface{}, intervals ...interface{}) AsyncAssertion { +// Eventually is used to make asynchronous assertions. See documentation for Eventually. +func (g *WithT) Eventually(actual interface{}, intervals ...interface{}) AsyncAssertion { timeoutInterval := defaultEventuallyTimeout pollingInterval := defaultEventuallyPollingInterval if len(intervals) > 0 { @@ -391,11 +386,11 @@ func (g *WithT) EventuallyWithOffset(offset int, actual interface{}, intervals . if len(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, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, 0) } -// ConsistentlyWithOffset is used to make asynchronous assertions. See documentation for ConsistentlyWithOffset. -func (g *WithT) ConsistentlyWithOffset(offset int, actual interface{}, intervals ...interface{}) AsyncAssertion { +// Consistently is used to make asynchronous assertions. See documentation for Consistently. +func (g *WithT) Consistently(actual interface{}, intervals ...interface{}) AsyncAssertion { timeoutInterval := defaultConsistentlyDuration pollingInterval := defaultConsistentlyPollingInterval if len(intervals) > 0 { @@ -404,22 +399,7 @@ func (g *WithT) ConsistentlyWithOffset(offset int, actual interface{}, intervals if len(intervals) > 1 { pollingInterval = toDuration(intervals[1]) } - return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, offset) -} - -// Expect is used to make assertions. See documentation for Expect. -func (g *WithT) Expect(actual interface{}, extra ...interface{}) Assertion { - return g.ExpectWithOffset(0, actual, extra...) -} - -// Eventually is used to make asynchronous assertions. See documentation for Eventually. -func (g *WithT) Eventually(actual interface{}, intervals ...interface{}) AsyncAssertion { - return g.EventuallyWithOffset(0, actual, intervals...) -} - -// Consistently is used to make asynchronous assertions. See documentation for Consistently. -func (g *WithT) Consistently(actual interface{}, intervals ...interface{}) AsyncAssertion { - return g.ConsistentlyWithOffset(0, actual, intervals...) + return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, 0) } func toDuration(input interface{}) time.Duration { @@ -447,32 +427,3 @@ func toDuration(input interface{}) time.Duration { panic(fmt.Sprintf("%v is not a valid interval. Must be time.Duration, parsable duration string or a number.", input)) } - -// Gomega describes the essential Gomega DSL. This interface allows libraries -// to abstract between the standard package-level function implementations -// and alternatives like *WithT. -type Gomega interface { - Expect(actual interface{}, extra ...interface{}) Assertion - Eventually(actual interface{}, intervals ...interface{}) AsyncAssertion - Consistently(actual interface{}, intervals ...interface{}) AsyncAssertion -} - -type globalFailHandlerGomega struct{} - -// DefaultGomega supplies the standard package-level implementation -var Default Gomega = globalFailHandlerGomega{} - -// Expect is used to make assertions. See documentation for Expect. -func (globalFailHandlerGomega) Expect(actual interface{}, extra ...interface{}) Assertion { - return Expect(actual, extra...) -} - -// Eventually is used to make asynchronous assertions. See documentation for Eventually. -func (globalFailHandlerGomega) Eventually(actual interface{}, extra ...interface{}) AsyncAssertion { - return Eventually(actual, extra...) -} - -// Consistently is used to make asynchronous assertions. See documentation for Consistently. -func (globalFailHandlerGomega) Consistently(actual interface{}, extra ...interface{}) AsyncAssertion { - return Consistently(actual, extra...) -} diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gstruct/elements.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gstruct/elements.go index b5e5ef2e45..30e3369e02 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gstruct/elements.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/gstruct/elements.go @@ -7,7 +7,6 @@ import ( "fmt" "reflect" "runtime/debug" - "strconv" "github.com/onsi/gomega/format" errorsutil "github.com/onsi/gomega/gstruct/errors" @@ -31,23 +30,6 @@ func MatchAllElements(identifier Identifier, elements Elements) types.GomegaMatc } } -//MatchAllElementsWithIndex succeeds if every element of a slice matches the element matcher it maps to -//through the id with index function, and every element matcher is matched. -// idFn := func(index int, element interface{}) string { -// return strconv.Itoa(index) -// } -// -// Expect([]string{"a", "b"}).To(MatchAllElements(idFn, Elements{ -// "0": Equal("a"), -// "1": Equal("b"), -// })) -func MatchAllElementsWithIndex(identifier IdentifierWithIndex, elements Elements) types.GomegaMatcher { - return &ElementsMatcher{ - Identifier: identifier, - Elements: elements, - } -} - //MatchElements succeeds if each element of a slice matches the element matcher it maps to //through the id function. It can ignore extra elements and/or missing elements. // idFn := func(element interface{}) string { @@ -74,32 +56,6 @@ func MatchElements(identifier Identifier, options Options, elements Elements) ty } } -//MatchElementsWithIndex succeeds if each element of a slice matches the element matcher it maps to -//through the id with index function. It can ignore extra elements and/or missing elements. -// idFn := func(index int, element interface{}) string { -// return strconv.Itoa(index) -// } -// -// Expect([]string{"a", "b", "c"}).To(MatchElements(idFn, IgnoreExtras, Elements{ -// "0": Equal("a"), -// "1": Equal("b"), -// })) -// Expect([]string{"a", "c"}).To(MatchElements(idFn, IgnoreMissing, Elements{ -// "0": Equal("a"), -// "1": Equal("b"), -// "2": Equal("c"), -// "3": Equal("d"), -// })) -func MatchElementsWithIndex(identifier IdentifierWithIndex, options Options, elements Elements) types.GomegaMatcher { - return &ElementsMatcher{ - Identifier: identifier, - Elements: elements, - IgnoreExtras: options&IgnoreExtras != 0, - IgnoreMissing: options&IgnoreMissing != 0, - AllowDuplicates: options&AllowDuplicates != 0, - } -} - // ElementsMatcher is a NestingMatcher that applies custom matchers to each element of a slice mapped // by the Identifier function. // TODO: Extend this to work with arrays & maps (map the key) as well. @@ -107,7 +63,7 @@ type ElementsMatcher struct { // Matchers for each element. Elements Elements // Function mapping an element to the string key identifying its matcher. - Identifier Identify + Identifier Identifier // Whether to ignore extra elements or consider it an error. IgnoreExtras bool @@ -126,32 +82,6 @@ type Elements map[string]types.GomegaMatcher // Function for identifying (mapping) elements. type Identifier func(element interface{}) string -// Calls the underlying fucntion with the provided params. -// Identifier drops the index. -func (i Identifier) WithIndexAndElement(index int, element interface{}) string { - return i(element) -} - -// Uses the index and element to generate an element name -type IdentifierWithIndex func(index int, element interface{}) string - -// Calls the underlying fucntion with the provided params. -// IdentifierWithIndex uses the index. -func (i IdentifierWithIndex) WithIndexAndElement(index int, element interface{}) string { - return i(index, element) -} - -// Interface for identifing the element -type Identify interface { - WithIndexAndElement(i int, element interface{}) string -} - -// IndexIdentity is a helper function for using an index as -// the key in the element map -func IndexIdentity(index int, _ interface{}) string { - return strconv.Itoa(index) -} - func (m *ElementsMatcher) Match(actual interface{}) (success bool, err error) { if reflect.TypeOf(actual).Kind() != reflect.Slice { return false, fmt.Errorf("%v is type %T, expected slice", actual, actual) @@ -176,7 +106,7 @@ func (m *ElementsMatcher) matchElements(actual interface{}) (errs []error) { elements := map[string]bool{} for i := 0; i < val.Len(); i++ { element := val.Index(i).Interface() - id := m.Identifier.WithIndexAndElement(i, element) + id := m.Identifier(element) if elements[id] { if !m.AllowDuplicates { errs = append(errs, fmt.Errorf("found duplicate element ID %s", id)) diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/assertion/assertion.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/assertion/assertion.go index a248298f47..00197b67a7 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/assertion/assertion.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/assertion/assertion.go @@ -52,19 +52,16 @@ func (assertion *Assertion) buildDescription(optionalDescription ...interface{}) switch len(optionalDescription) { case 0: return "" - case 1: - if describe, ok := optionalDescription[0].(func() string); ok { - return describe() + "\n" - } + default: + return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n" } - return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n" } func (assertion *Assertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool { matches, err := matcher.Match(assertion.actualInput) + description := assertion.buildDescription(optionalDescription...) assertion.failWrapper.TWithHelper.Helper() if err != nil { - description := assertion.buildDescription(optionalDescription...) assertion.failWrapper.Fail(description+err.Error(), 2+assertion.offset) return false } @@ -75,7 +72,6 @@ func (assertion *Assertion) match(matcher types.GomegaMatcher, desiredMatch bool } else { message = matcher.NegatedFailureMessage(assertion.actualInput) } - description := assertion.buildDescription(optionalDescription...) assertion.failWrapper.Fail(description+message, 2+assertion.offset) return false } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go index 5204836bff..a233e48c01 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go @@ -60,12 +60,9 @@ func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interfa switch len(optionalDescription) { case 0: return "" - case 1: - if describe, ok := optionalDescription[0].(func() string); ok { - return describe() + "\n" - } + default: + return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n" } - return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n" } func (assertion *AsyncAssertion) actualInputIsAFunction() bool { @@ -106,6 +103,8 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch timer := time.Now() timeout := time.After(assertion.timeoutInterval) + description := assertion.buildDescription(optionalDescription...) + var matches bool var err error mayChange := true @@ -130,7 +129,6 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch } } assertion.failWrapper.TWithHelper.Helper() - description := assertion.buildDescription(optionalDescription...) assertion.failWrapper.Fail(fmt.Sprintf("%s after %.3fs.\n%s%s%s", preamble, time.Since(timer).Seconds(), description, message, errMsg), 3+assertion.offset) } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers.go index 667160ade8..9ec8893cba 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers.go @@ -306,20 +306,6 @@ func ConsistOf(elements ...interface{}) types.GomegaMatcher { } } -//ContainElements succeeds if actual contains the passed in elements. The ordering of the elements does not matter. -//By default ContainElements() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples: -// -// Expect([]string{"Foo", "FooBar"}).Should(ContainElements("FooBar")) -// Expect([]string{"Foo", "FooBar"}).Should(ContainElements(ContainSubstring("Bar"), "Foo")) -// -//Actual must be an array, slice or map. -//For maps, ContainElements searches through the map's values. -func ContainElements(elements ...interface{}) types.GomegaMatcher { - return &matchers.ContainElementsMatcher{ - Elements: elements, - } -} - //HaveKey succeeds if actual is a map with the passed in key. //By default HaveKey uses Equal() to perform the match, however a //matcher can be passed in instead: @@ -390,16 +376,6 @@ func Panic() types.GomegaMatcher { return &matchers.PanicMatcher{} } -//PanicWith succeeds if actual is a function that, when invoked, panics with a specific value. -//Actual must be a function that takes no arguments and returns no results. -// -//By default PanicWith uses Equal() to perform the match, however a -//matcher can be passed in instead: -// Expect(fn).Should(PanicWith(MatchRegexp(`.+Foo$`))) -func PanicWith(expected interface{}) types.GomegaMatcher { - return &matchers.PanicMatcher{Expected: expected} -} - //BeAnExistingFile succeeds if a file exists. //Actual must be a string representing the abs path to the file being checked. func BeAnExistingFile() types.GomegaMatcher { @@ -418,15 +394,6 @@ func BeADirectory() types.GomegaMatcher { return &matchers.BeADirectoryMatcher{} } -//HaveHTTPStatus succeeds if the Status or StatusCode field of an HTTP response matches. -//Actual must be either a *http.Response or *httptest.ResponseRecorder. -//Expected must be either an int or a string. -// Expect(resp).Should(HaveHTTPStatus(http.StatusOK)) // asserts that resp.StatusCode == 200 -// Expect(resp).Should(HaveHTTPStatus("404 Not Found")) // asserts that resp.Status == "404 Not Found" -func HaveHTTPStatus(expected interface{}) types.GomegaMatcher { - return &matchers.HaveHTTPStatusMatcher{Expected: expected} -} - //And succeeds only if all of the given matchers succeed. //The matchers are tried in order, and will fail-fast if one doesn't succeed. // Expect("hi").To(And(HaveLen(2), Equal("hi")) @@ -474,11 +441,3 @@ func Not(matcher types.GomegaMatcher) types.GomegaMatcher { func WithTransform(transform interface{}, matcher types.GomegaMatcher) types.GomegaMatcher { return matchers.NewWithTransformMatcher(transform, matcher) } - -//Satisfy matches the actual value against the `predicate` function. -//The given predicate must be a function of one paramter that returns bool. -// var isEven = func(i int) bool { return i%2 == 0 } -// Expect(2).To(Satisfy(isEven)) -func Satisfy(predicate interface{}) types.GomegaMatcher { - return matchers.NewSatisfyMatcher(predicate) -} diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go index 9ee75a5d51..1f9d7a8e62 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go @@ -18,9 +18,23 @@ func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err return false, fmt.Errorf("BeElement matcher expects actual to be typed") } + length := len(matcher.Elements) + valueAt := func(i int) interface{} { + return matcher.Elements[i] + } + // Special handling of a single element of type Array or Slice + if length == 1 && isArrayOrSlice(valueAt(0)) { + element := valueAt(0) + value := reflect.ValueOf(element) + length = value.Len() + valueAt = func(i int) interface{} { + return value.Index(i).Interface() + } + } + var lastError error - for _, m := range flatten(matcher.Elements) { - matcher := &EqualMatcher{Expected: m} + for i := 0; i < length; i++ { + matcher := &EqualMatcher{Expected: valueAt(i)} success, err := matcher.Match(actual) if err != nil { lastError = err @@ -35,9 +49,9 @@ func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err } func (matcher *BeElementOfMatcher) FailureMessage(actual interface{}) (message string) { - return format.Message(actual, "to be an element of", presentable(matcher.Elements)) + return format.Message(actual, "to be an element of", matcher.Elements) } func (matcher *BeElementOfMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to be an element of", presentable(matcher.Elements)) + return format.Message(actual, "not to be an element of", matcher.Elements) } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go index 100735de32..f72591a1a8 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go @@ -45,7 +45,7 @@ func (matcher *BeNumericallyMatcher) Match(actual interface{}) (success bool, er return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1)) } if len(matcher.CompareTo) == 2 && !isNumber(matcher.CompareTo[1]) { - return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[1], 1)) + return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1)) } switch matcher.Comparator { diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/consist_of.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/consist_of.go index e8ef0dee1f..cbbf618029 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/consist_of.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/consist_of.go @@ -11,9 +11,7 @@ import ( ) type ConsistOfMatcher struct { - Elements []interface{} - missingElements []interface{} - extraElements []interface{} + Elements []interface{} } func (matcher *ConsistOfMatcher) Match(actual interface{}) (success bool, err error) { @@ -21,90 +19,44 @@ func (matcher *ConsistOfMatcher) Match(actual interface{}) (success bool, err er return false, fmt.Errorf("ConsistOf matcher expects an array/slice/map. Got:\n%s", format.Object(actual, 1)) } - matchers := matchers(matcher.Elements) - values := valuesOf(actual) - - bipartiteGraph, err := bipartitegraph.NewBipartiteGraph(values, matchers, neighbours) - if err != nil { - return false, err - } - - edges := bipartiteGraph.LargestMatching() - if len(edges) == len(values) && len(edges) == len(matchers) { - return true, nil - } - - var missingMatchers []interface{} - matcher.extraElements, missingMatchers = bipartiteGraph.FreeLeftRight(edges) - matcher.missingElements = equalMatchersToElements(missingMatchers) - - return false, nil -} - -func neighbours(value, matcher interface{}) (bool, error) { - match, err := matcher.(omegaMatcher).Match(value) - return match && err == nil, nil -} - -func equalMatchersToElements(matchers []interface{}) (elements []interface{}) { - for _, matcher := range matchers { - equalMatcher, ok := matcher.(*EqualMatcher) - if ok { - matcher = equalMatcher.Expected + elements := matcher.Elements + if len(matcher.Elements) == 1 && isArrayOrSlice(matcher.Elements[0]) { + elements = []interface{}{} + value := reflect.ValueOf(matcher.Elements[0]) + for i := 0; i < value.Len(); i++ { + elements = append(elements, value.Index(i).Interface()) } - elements = append(elements, matcher) } - return -} -func flatten(elems []interface{}) []interface{} { - if len(elems) != 1 || !isArrayOrSlice(elems[0]) { - return elems - } - - value := reflect.ValueOf(elems[0]) - flattened := make([]interface{}, value.Len()) - for i := 0; i < value.Len(); i++ { - flattened[i] = value.Index(i).Interface() - } - return flattened -} - -func matchers(expectedElems []interface{}) (matchers []interface{}) { - for _, e := range flatten(expectedElems) { - matcher, isMatcher := e.(omegaMatcher) + matchers := []interface{}{} + for _, element := range elements { + matcher, isMatcher := element.(omegaMatcher) if !isMatcher { - matcher = &EqualMatcher{Expected: e} + matcher = &EqualMatcher{Expected: element} } matchers = append(matchers, matcher) } - return -} -func presentable(elems []interface{}) interface{} { - elems = flatten(elems) + values := matcher.valuesOf(actual) - if len(elems) == 0 { - return []interface{}{} + if len(values) != len(matchers) { + return false, nil } - sv := reflect.ValueOf(elems) - tt := sv.Index(0).Elem().Type() - for i := 1; i < sv.Len(); i++ { - if sv.Index(i).Elem().Type() != tt { - return elems - } + neighbours := func(v, m interface{}) (bool, error) { + match, err := m.(omegaMatcher).Match(v) + return match && err == nil, nil } - ss := reflect.MakeSlice(reflect.SliceOf(tt), sv.Len(), sv.Len()) - for i := 0; i < sv.Len(); i++ { - ss.Index(i).Set(sv.Index(i).Elem()) + bipartiteGraph, err := bipartitegraph.NewBipartiteGraph(values, matchers, neighbours) + if err != nil { + return false, err } - return ss.Interface() + return len(bipartiteGraph.LargestMatching()) == len(values), nil } -func valuesOf(actual interface{}) []interface{} { +func (matcher *ConsistOfMatcher) valuesOf(actual interface{}) []interface{} { value := reflect.ValueOf(actual) values := []interface{}{} if isMap(actual) { @@ -122,23 +74,9 @@ func valuesOf(actual interface{}) []interface{} { } func (matcher *ConsistOfMatcher) FailureMessage(actual interface{}) (message string) { - message = format.Message(actual, "to consist of", presentable(matcher.Elements)) - message = appendMissingElements(message, matcher.missingElements) - if len(matcher.extraElements) > 0 { - message = fmt.Sprintf("%s\nthe extra elements were\n%s", message, - format.Object(presentable(matcher.extraElements), 1)) - } - return -} - -func appendMissingElements(message string, missingElements []interface{}) string { - if len(missingElements) == 0 { - return message - } - return fmt.Sprintf("%s\nthe missing elements were\n%s", message, - format.Object(presentable(missingElements), 1)) + return format.Message(actual, "to consist of", matcher.Elements) } func (matcher *ConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to consist of", presentable(matcher.Elements)) + return format.Message(actual, "not to consist of", matcher.Elements) } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/contain_elements_matcher.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/contain_elements_matcher.go deleted file mode 100644 index 946cd8bea5..0000000000 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/contain_elements_matcher.go +++ /dev/null @@ -1,44 +0,0 @@ -package matchers - -import ( - "fmt" - - "github.com/onsi/gomega/format" - "github.com/onsi/gomega/matchers/support/goraph/bipartitegraph" -) - -type ContainElementsMatcher struct { - Elements []interface{} - missingElements []interface{} -} - -func (matcher *ContainElementsMatcher) Match(actual interface{}) (success bool, err error) { - if !isArrayOrSlice(actual) && !isMap(actual) { - return false, fmt.Errorf("ContainElements matcher expects an array/slice/map. Got:\n%s", format.Object(actual, 1)) - } - - matchers := matchers(matcher.Elements) - bipartiteGraph, err := bipartitegraph.NewBipartiteGraph(valuesOf(actual), matchers, neighbours) - if err != nil { - return false, err - } - - edges := bipartiteGraph.LargestMatching() - if len(edges) == len(matchers) { - return true, nil - } - - _, missingMatchers := bipartiteGraph.FreeLeftRight(edges) - matcher.missingElements = equalMatchersToElements(missingMatchers) - - return false, nil -} - -func (matcher *ContainElementsMatcher) FailureMessage(actual interface{}) (message string) { - message = format.Message(actual, "to contain elements", presentable(matcher.Elements)) - return appendMissingElements(message, matcher.missingElements) -} - -func (matcher *ContainElementsMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to contain elements", presentable(matcher.Elements)) -} diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go deleted file mode 100644 index 3ce4800b73..0000000000 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go +++ /dev/null @@ -1,42 +0,0 @@ -package matchers - -import ( - "fmt" - "net/http" - "net/http/httptest" - - "github.com/onsi/gomega/format" -) - -type HaveHTTPStatusMatcher struct { - Expected interface{} -} - -func (matcher *HaveHTTPStatusMatcher) Match(actual interface{}) (success bool, err error) { - var resp *http.Response - switch a := actual.(type) { - case *http.Response: - resp = a - case *httptest.ResponseRecorder: - resp = a.Result() - default: - return false, fmt.Errorf("HaveHTTPStatus matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1)) - } - - switch e := matcher.Expected.(type) { - case int: - return resp.StatusCode == e, nil - case string: - return resp.Status == e, nil - } - - return false, fmt.Errorf("HaveHTTPStatus matcher must be passed an int or a string. Got:\n%s", format.Object(matcher.Expected, 1)) -} - -func (matcher *HaveHTTPStatusMatcher) FailureMessage(actual interface{}) (message string) { - return format.Message(actual, "to have HTTP status", matcher.Expected) -} - -func (matcher *HaveHTTPStatusMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "not to have HTTP status", matcher.Expected) -} diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go index c8993a86d9..07499ac959 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go @@ -1,7 +1,6 @@ package matchers import ( - "errors" "fmt" "reflect" @@ -22,28 +21,25 @@ func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err e } actualErr := actual.(error) - expected := matcher.Expected - if isError(expected) { - return reflect.DeepEqual(actualErr, expected) || errors.Is(actualErr, expected.(error)), nil + if isError(matcher.Expected) { + return reflect.DeepEqual(actualErr, matcher.Expected), nil } - if isString(expected) { - return actualErr.Error() == expected, nil + if isString(matcher.Expected) { + return actualErr.Error() == matcher.Expected, nil } var subMatcher omegaMatcher var hasSubMatcher bool - if expected != nil { - subMatcher, hasSubMatcher = (expected).(omegaMatcher) + if matcher.Expected != nil { + subMatcher, hasSubMatcher = (matcher.Expected).(omegaMatcher) if hasSubMatcher { return subMatcher.Match(actualErr.Error()) } } - return false, fmt.Errorf( - "MatchError must be passed an error, a string, or a Matcher that can match on strings. Got:\n%s", - format.Object(expected, 1)) + return false, fmt.Errorf("MatchError must be passed an error, string, or Matcher that can match on strings. Got:\n%s", format.Object(matcher.Expected, 1)) } func (matcher *MatchErrorMatcher) FailureMessage(actual interface{}) (message string) { diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/panic_matcher.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/panic_matcher.go index adc8cee630..640f4db1a3 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/panic_matcher.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/panic_matcher.go @@ -8,8 +8,7 @@ import ( ) type PanicMatcher struct { - Expected interface{} - object interface{} + object interface{} } func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) { @@ -29,21 +28,7 @@ func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) defer func() { if e := recover(); e != nil { matcher.object = e - - if matcher.Expected == nil { - success = true - return - } - - valueMatcher, valueIsMatcher := matcher.Expected.(omegaMatcher) - if !valueIsMatcher { - valueMatcher = &EqualMatcher{Expected: matcher.Expected} - } - - success, err = valueMatcher.Match(e) - if err != nil { - err = fmt.Errorf("PanicMatcher's value matcher failed with:\n%s%s", format.Indent, err.Error()) - } + success = true } }() @@ -53,62 +38,9 @@ func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) } func (matcher *PanicMatcher) FailureMessage(actual interface{}) (message string) { - if matcher.Expected == nil { - // We wanted any panic to occur, but none did. - return format.Message(actual, "to panic") - } - - if matcher.object == nil { - // We wanted a panic with a specific value to occur, but none did. - switch matcher.Expected.(type) { - case omegaMatcher: - return format.Message(actual, "to panic with a value matching", matcher.Expected) - default: - return format.Message(actual, "to panic with", matcher.Expected) - } - } - - // We got a panic, but the value isn't what we expected. - switch matcher.Expected.(type) { - case omegaMatcher: - return format.Message( - actual, - fmt.Sprintf( - "to panic with a value matching\n%s\nbut panicked with\n%s", - format.Object(matcher.Expected, 1), - format.Object(matcher.object, 1), - ), - ) - default: - return format.Message( - actual, - fmt.Sprintf( - "to panic with\n%s\nbut panicked with\n%s", - format.Object(matcher.Expected, 1), - format.Object(matcher.object, 1), - ), - ) - } + return format.Message(actual, "to panic") } func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) { - if matcher.Expected == nil { - // We didn't want any panic to occur, but one did. - return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1))) - } - - // We wanted a to ensure a panic with a specific value did not occur, but it did. - switch matcher.Expected.(type) { - case omegaMatcher: - return format.Message( - actual, - fmt.Sprintf( - "not to panic with a value matching\n%s\nbut panicked with\n%s", - format.Object(matcher.Expected, 1), - format.Object(matcher.object, 1), - ), - ) - default: - return format.Message(actual, "not to panic with", matcher.Expected) - } + return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1))) } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go deleted file mode 100644 index ec68fe8b62..0000000000 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go +++ /dev/null @@ -1,66 +0,0 @@ -package matchers - -import ( - "fmt" - "reflect" - - "github.com/onsi/gomega/format" -) - -type SatisfyMatcher struct { - Predicate interface{} - - // cached type - predicateArgType reflect.Type -} - -func NewSatisfyMatcher(predicate interface{}) *SatisfyMatcher { - if predicate == nil { - panic("predicate cannot be nil") - } - predicateType := reflect.TypeOf(predicate) - if predicateType.Kind() != reflect.Func { - panic("predicate must be a function") - } - if predicateType.NumIn() != 1 { - panic("predicate must have 1 argument") - } - if predicateType.NumOut() != 1 || predicateType.Out(0).Kind() != reflect.Bool { - panic("predicate must return bool") - } - - return &SatisfyMatcher{ - Predicate: predicate, - predicateArgType: predicateType.In(0), - } -} - -func (m *SatisfyMatcher) Match(actual interface{}) (success bool, err error) { - // prepare a parameter to pass to the predicate - var param reflect.Value - if actual != nil && reflect.TypeOf(actual).AssignableTo(m.predicateArgType) { - // The dynamic type of actual is compatible with the predicate argument. - param = reflect.ValueOf(actual) - - } else if actual == nil && m.predicateArgType.Kind() == reflect.Interface { - // The dynamic type of actual is unknown, so there's no way to make its - // reflect.Value. Create a nil of the predicate argument, which is known. - param = reflect.Zero(m.predicateArgType) - - } else { - return false, fmt.Errorf("predicate expects '%s' but we have '%T'", m.predicateArgType, actual) - } - - // call the predicate with `actual` - fn := reflect.ValueOf(m.Predicate) - result := fn.Call([]reflect.Value{param}) - return result[0].Bool(), nil -} - -func (m *SatisfyMatcher) FailureMessage(actual interface{}) (message string) { - return format.Message(actual, "to satisfy predicate", m.Predicate) -} - -func (m *SatisfyMatcher) NegatedFailureMessage(actual interface{}) (message string) { - return format.Message(actual, "to not satisfy predicate", m.Predicate) -} diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go index 830e308274..108f285866 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go @@ -13,13 +13,13 @@ type BipartiteGraph struct { func NewBipartiteGraph(leftValues, rightValues []interface{}, neighbours func(interface{}, interface{}) (bool, error)) (*BipartiteGraph, error) { left := NodeOrderedSet{} - for i, v := range leftValues { - left = append(left, Node{ID: i, Value: v}) + for i := range leftValues { + left = append(left, Node{Id: i}) } right := NodeOrderedSet{} - for j, v := range rightValues { - right = append(right, Node{ID: j + len(left), Value: v}) + for j := range rightValues { + right = append(right, Node{Id: j + len(left)}) } edges := EdgeSet{} @@ -31,26 +31,10 @@ func NewBipartiteGraph(leftValues, rightValues []interface{}, neighbours func(in } if neighbours { - edges = append(edges, Edge{Node1: left[i].ID, Node2: right[j].ID}) + edges = append(edges, Edge{Node1: left[i], Node2: right[j]}) } } } return &BipartiteGraph{left, right, edges}, nil } - -// FreeLeftRight returns left node values and right node values -// of the BipartiteGraph's nodes which are not part of the given edges. -func (bg *BipartiteGraph) FreeLeftRight(edges EdgeSet) (leftValues, rightValues []interface{}) { - for _, node := range bg.Left { - if edges.Free(node) { - leftValues = append(leftValues, node.Value) - } - } - for _, node := range bg.Right { - if edges.Free(node) { - rightValues = append(rightValues, node.Value) - } - } - return -} diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go index 1c54edd8f1..8181f43a40 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go @@ -1,14 +1,9 @@ package bipartitegraph -import ( - . "github.com/onsi/gomega/matchers/support/goraph/edge" - . "github.com/onsi/gomega/matchers/support/goraph/node" - "github.com/onsi/gomega/matchers/support/goraph/util" -) - -// LargestMatching implements the Hopcroft–Karp algorithm taking as input a bipartite graph -// and outputting a maximum cardinality matching, i.e. a set of as many edges as possible -// with the property that no two edges share an endpoint. +import . "github.com/onsi/gomega/matchers/support/goraph/node" +import . "github.com/onsi/gomega/matchers/support/goraph/edge" +import "github.com/onsi/gomega/matchers/support/goraph/util" + func (bg *BipartiteGraph) LargestMatching() (matching EdgeSet) { paths := bg.maximalDisjointSLAPCollection(matching) @@ -28,7 +23,7 @@ func (bg *BipartiteGraph) maximalDisjointSLAPCollection(matching EdgeSet) (resul return } - used := make(map[int]bool) + used := make(map[Node]bool) for _, u := range guideLayers[len(guideLayers)-1] { slap, found := bg.findDisjointSLAP(u, matching, guideLayers, used) @@ -48,7 +43,7 @@ func (bg *BipartiteGraph) findDisjointSLAP( start Node, matching EdgeSet, guideLayers []NodeOrderedSet, - used map[int]bool, + used map[Node]bool, ) ([]Edge, bool) { return bg.findDisjointSLAPHelper(start, EdgeSet{}, len(guideLayers)-1, matching, guideLayers, used) } @@ -59,16 +54,16 @@ func (bg *BipartiteGraph) findDisjointSLAPHelper( currentLevel int, matching EdgeSet, guideLayers []NodeOrderedSet, - used map[int]bool, + used map[Node]bool, ) (EdgeSet, bool) { - used[currentNode.ID] = true + used[currentNode] = true if currentLevel == 0 { return currentSLAP, true } for _, nextNode := range guideLayers[currentLevel-1] { - if used[nextNode.ID] { + if used[nextNode] { continue } @@ -89,17 +84,17 @@ func (bg *BipartiteGraph) findDisjointSLAPHelper( currentSLAP = currentSLAP[:len(currentSLAP)-1] } - used[currentNode.ID] = false + used[currentNode] = false return nil, false } func (bg *BipartiteGraph) createSLAPGuideLayers(matching EdgeSet) (guideLayers []NodeOrderedSet) { - used := make(map[int]bool) + used := make(map[Node]bool) currentLayer := NodeOrderedSet{} for _, node := range bg.Left { if matching.Free(node) { - used[node.ID] = true + used[node] = true currentLayer = append(currentLayer, node) } } @@ -118,7 +113,7 @@ func (bg *BipartiteGraph) createSLAPGuideLayers(matching EdgeSet) (guideLayers [ if util.Odd(len(guideLayers)) { for _, leftNode := range lastLayer { for _, rightNode := range bg.Right { - if used[rightNode.ID] { + if used[rightNode] { continue } @@ -128,7 +123,7 @@ func (bg *BipartiteGraph) createSLAPGuideLayers(matching EdgeSet) (guideLayers [ } currentLayer = append(currentLayer, rightNode) - used[rightNode.ID] = true + used[rightNode] = true if matching.Free(rightNode) { done = true @@ -138,7 +133,7 @@ func (bg *BipartiteGraph) createSLAPGuideLayers(matching EdgeSet) (guideLayers [ } else { for _, rightNode := range lastLayer { for _, leftNode := range bg.Left { - if used[leftNode.ID] { + if used[leftNode] { continue } @@ -148,7 +143,7 @@ func (bg *BipartiteGraph) createSLAPGuideLayers(matching EdgeSet) (guideLayers [ } currentLayer = append(currentLayer, leftNode) - used[leftNode.ID] = true + used[leftNode] = true } } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go index 8c38411b28..4fd15cc069 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go @@ -3,15 +3,15 @@ package edge import . "github.com/onsi/gomega/matchers/support/goraph/node" type Edge struct { - Node1 int - Node2 int + Node1 Node + Node2 Node } type EdgeSet []Edge func (ec EdgeSet) Free(node Node) bool { for _, e := range ec { - if e.Node1 == node.ID || e.Node2 == node.ID { + if e.Node1 == node || e.Node2 == node { return false } } @@ -31,7 +31,7 @@ func (ec EdgeSet) Contains(edge Edge) bool { func (ec EdgeSet) FindByNodes(node1, node2 Node) (Edge, bool) { for _, e := range ec { - if (e.Node1 == node1.ID && e.Node2 == node2.ID) || (e.Node1 == node2.ID && e.Node2 == node1.ID) { + if (e.Node1 == node1 && e.Node2 == node2) || (e.Node1 == node2 && e.Node2 == node1) { return e, true } } diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go index cd597a2f22..800c2ea8ca 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go @@ -1,8 +1,7 @@ package node type Node struct { - ID int - Value interface{} + Id int } type NodeOrderedSet []Node diff --git a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/with_transform.go b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/with_transform.go index f3dec91010..8e58d8a0fb 100644 --- a/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/with_transform.go +++ b/src/code.cloudfoundry.org/vendor/github.com/onsi/gomega/matchers/with_transform.go @@ -40,24 +40,15 @@ func NewWithTransformMatcher(transform interface{}, matcher types.GomegaMatcher) } func (m *WithTransformMatcher) Match(actual interface{}) (bool, error) { - // prepare a parameter to pass to the Transform function - var param reflect.Value - if actual != nil && reflect.TypeOf(actual).AssignableTo(m.transformArgType) { - // The dynamic type of actual is compatible with the transform argument. - param = reflect.ValueOf(actual) - - } else if actual == nil && m.transformArgType.Kind() == reflect.Interface { - // The dynamic type of actual is unknown, so there's no way to make its - // reflect.Value. Create a nil of the transform argument, which is known. - param = reflect.Zero(m.transformArgType) - - } else { - return false, fmt.Errorf("Transform function expects '%s' but we have '%T'", m.transformArgType, actual) + // return error if actual's type is incompatible with Transform function's argument type + actualType := reflect.TypeOf(actual) + if !actualType.AssignableTo(m.transformArgType) { + return false, fmt.Errorf("Transform function expects '%s' but we have '%s'", m.transformArgType, actualType) } // call the Transform function with `actual` fn := reflect.ValueOf(m.Transform) - result := fn.Call([]reflect.Value{param}) + result := fn.Call([]reflect.Value{reflect.ValueOf(actual)}) m.transformedValue = result[0].Interface() // expect exactly one value return m.Matcher.Match(m.transformedValue) diff --git a/src/code.cloudfoundry.org/vendor/modules.txt b/src/code.cloudfoundry.org/vendor/modules.txt index ac3326e104..200ed5c674 100644 --- a/src/code.cloudfoundry.org/vendor/modules.txt +++ b/src/code.cloudfoundry.org/vendor/modules.txt @@ -506,7 +506,7 @@ github.com/onsi/ginkgo/reporters/stenographer github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty github.com/onsi/ginkgo/types -# github.com/onsi/gomega v1.12.0 +# github.com/onsi/gomega v1.12.0 => github.com/onsi/gomega v1.7.0 ## explicit github.com/onsi/gomega github.com/onsi/gomega/format @@ -757,3 +757,4 @@ gopkg.in/yaml.v2 # github.com/golang/protobuf => github.com/golang/protobuf v1.3.2 # github.com/gogo/protobuf => github.com/gogo/protobuf v1.2.0 # google.golang.org/genproto => google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 +# github.com/onsi/gomega => github.com/onsi/gomega v1.7.0