mirror of https://github.com/containers/podman.git
Bump github.com/onsi/gomega from 1.5.0 to 1.7.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.5.0 to 1.7.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.5.0...v1.7.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
parent
d7eba02687
commit
6c72b5c592
2
go.mod
2
go.mod
|
|
@ -62,7 +62,7 @@ require (
|
||||||
github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618
|
github.com/mrunalp/fileutils v0.0.0-20171103030105-7d4729fb3618
|
||||||
github.com/munnerz/goautoneg v0.0.0-20190414153302-2ae31c8b6b30 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20190414153302-2ae31c8b6b30 // indirect
|
||||||
github.com/onsi/ginkgo v1.10.1
|
github.com/onsi/ginkgo v1.10.1
|
||||||
github.com/onsi/gomega v1.5.0
|
github.com/onsi/gomega v1.7.0
|
||||||
github.com/opencontainers/go-digest v1.0.0-rc1
|
github.com/opencontainers/go-digest v1.0.0-rc1
|
||||||
github.com/opencontainers/image-spec v1.0.1
|
github.com/opencontainers/image-spec v1.0.1
|
||||||
github.com/opencontainers/runc v1.0.0-rc8.0.20190827142921-dd075602f158
|
github.com/opencontainers/runc v1.0.0-rc8.0.20190827142921-dd075602f158
|
||||||
|
|
|
||||||
2
go.sum
2
go.sum
|
|
@ -395,6 +395,8 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
|
github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=
|
||||||
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
|
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
||||||
|
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||||
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
|
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
|
||||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ go:
|
||||||
- 1.10.x
|
- 1.10.x
|
||||||
- 1.11.x
|
- 1.11.x
|
||||||
- 1.12.x
|
- 1.12.x
|
||||||
|
- gotip
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- GO111MODULE=on
|
- GO111MODULE=on
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,35 @@
|
||||||
|
## 1.7.0
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- export format property variables (#347) [642e5ba]
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- minor fix in the documentation of ExpectWithOffset (#358) [beea727]
|
||||||
|
|
||||||
|
## 1.6.0
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Display special chars on error [41e1b26]
|
||||||
|
- Add BeElementOf matcher [6a48b48]
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- Remove duplication in XML matcher tests [cc1a6cb]
|
||||||
|
- Remove unnecessary conversions (#357) [7bf756a]
|
||||||
|
- Fixed import order (#353) [2e3b965]
|
||||||
|
- Added missing error handling in test (#355) [c98d3eb]
|
||||||
|
- Simplify code (#356) [0001ed9]
|
||||||
|
- Simplify code (#354) [0d9100e]
|
||||||
|
- Fixed typos (#352) [3f647c4]
|
||||||
|
- Add failure message tests to BeElementOf matcher [efe19c3]
|
||||||
|
- Update go-testcov untested sections [37ee382]
|
||||||
|
- Mark all uncovered files so go-testcov ./... works [53b150e]
|
||||||
|
- Reenable gotip in travis [5c249dc]
|
||||||
|
- Fix the typo of comment (#345) [f0e010e]
|
||||||
|
- Optimize contain_element_matcher [abeb93d]
|
||||||
|
|
||||||
|
|
||||||
## 1.5.0
|
## 1.5.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
/*
|
/*
|
||||||
Gomega's format package pretty-prints objects. It explores input objects recursively and generates formatted, indented output with type information.
|
Gomega's format package pretty-prints objects. It explores input objects recursively and generates formatted, indented output with type information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// untested sections: 4
|
||||||
|
|
||||||
package format
|
package format
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -33,7 +36,15 @@ var PrintContextObjects = false
|
||||||
// TruncatedDiff choose if we should display a truncated pretty diff or not
|
// TruncatedDiff choose if we should display a truncated pretty diff or not
|
||||||
var TruncatedDiff = true
|
var TruncatedDiff = true
|
||||||
|
|
||||||
// Ctx interface defined here to keep backwards compatability with go < 1.7
|
// TruncateThreshold (default 50) specifies the maximum length string to print in string comparison assertion error
|
||||||
|
// messages.
|
||||||
|
var TruncateThreshold uint = 50
|
||||||
|
|
||||||
|
// CharactersAroundMismatchToInclude (default 5) specifies how many contextual characters should be printed before and
|
||||||
|
// after the first diff location in a truncated string assertion error message.
|
||||||
|
var CharactersAroundMismatchToInclude uint = 5
|
||||||
|
|
||||||
|
// Ctx interface defined here to keep backwards compatibility with go < 1.7
|
||||||
// It matches the context.Context interface
|
// It matches the context.Context interface
|
||||||
type Ctx interface {
|
type Ctx interface {
|
||||||
Deadline() (deadline time.Time, ok bool)
|
Deadline() (deadline time.Time, ok bool)
|
||||||
|
|
@ -58,7 +69,7 @@ Generates a formatted matcher success/failure message of the form:
|
||||||
<message>
|
<message>
|
||||||
<pretty printed expected>
|
<pretty printed expected>
|
||||||
|
|
||||||
If expected is omited, then the message looks like:
|
If expected is omitted, then the message looks like:
|
||||||
|
|
||||||
Expected
|
Expected
|
||||||
<pretty printed actual>
|
<pretty printed actual>
|
||||||
|
|
@ -85,7 +96,7 @@ to equal |
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func MessageWithDiff(actual, message, expected string) string {
|
func MessageWithDiff(actual, message, expected string) string {
|
||||||
if TruncatedDiff && len(actual) >= truncateThreshold && len(expected) >= truncateThreshold {
|
if TruncatedDiff && len(actual) >= int(TruncateThreshold) && len(expected) >= int(TruncateThreshold) {
|
||||||
diffPoint := findFirstMismatch(actual, expected)
|
diffPoint := findFirstMismatch(actual, expected)
|
||||||
formattedActual := truncateAndFormat(actual, diffPoint)
|
formattedActual := truncateAndFormat(actual, diffPoint)
|
||||||
formattedExpected := truncateAndFormat(expected, diffPoint)
|
formattedExpected := truncateAndFormat(expected, diffPoint)
|
||||||
|
|
@ -97,14 +108,23 @@ func MessageWithDiff(actual, message, expected string) string {
|
||||||
padding := strings.Repeat(" ", spaceFromMessageToActual+spacesBeforeFormattedMismatch) + "|"
|
padding := strings.Repeat(" ", spaceFromMessageToActual+spacesBeforeFormattedMismatch) + "|"
|
||||||
return Message(formattedActual, message+padding, formattedExpected)
|
return Message(formattedActual, message+padding, formattedExpected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actual = escapedWithGoSyntax(actual)
|
||||||
|
expected = escapedWithGoSyntax(expected)
|
||||||
|
|
||||||
return Message(actual, message, expected)
|
return Message(actual, message, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func escapedWithGoSyntax(str string) string {
|
||||||
|
withQuotes := fmt.Sprintf("%q", str)
|
||||||
|
return withQuotes[1 : len(withQuotes)-1]
|
||||||
|
}
|
||||||
|
|
||||||
func truncateAndFormat(str string, index int) string {
|
func truncateAndFormat(str string, index int) string {
|
||||||
leftPadding := `...`
|
leftPadding := `...`
|
||||||
rightPadding := `...`
|
rightPadding := `...`
|
||||||
|
|
||||||
start := index - charactersAroundMismatchToInclude
|
start := index - int(CharactersAroundMismatchToInclude)
|
||||||
if start < 0 {
|
if start < 0 {
|
||||||
start = 0
|
start = 0
|
||||||
leftPadding = ""
|
leftPadding = ""
|
||||||
|
|
@ -112,7 +132,7 @@ func truncateAndFormat(str string, index int) string {
|
||||||
|
|
||||||
// slice index must include the mis-matched character
|
// slice index must include the mis-matched character
|
||||||
lengthOfMismatchedCharacter := 1
|
lengthOfMismatchedCharacter := 1
|
||||||
end := index + charactersAroundMismatchToInclude + lengthOfMismatchedCharacter
|
end := index + int(CharactersAroundMismatchToInclude) + lengthOfMismatchedCharacter
|
||||||
if end > len(str) {
|
if end > len(str) {
|
||||||
end = len(str)
|
end = len(str)
|
||||||
rightPadding = ""
|
rightPadding = ""
|
||||||
|
|
@ -141,11 +161,6 @@ func findFirstMismatch(a, b string) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
truncateThreshold = 50
|
|
||||||
charactersAroundMismatchToInclude = 5
|
|
||||||
)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Pretty prints the passed in object at the passed in indentation level.
|
Pretty prints the passed in object at the passed in indentation level.
|
||||||
|
|
||||||
|
|
@ -288,7 +303,7 @@ func formatString(object interface{}, indentation uint) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s", result)
|
return result
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf("%q", object)
|
return fmt.Sprintf("%q", object)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 1
|
||||||
|
|
||||||
package gbytes
|
package gbytes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -19,7 +21,7 @@ Say is a Gomega matcher that operates on gbytes.Buffers:
|
||||||
|
|
||||||
will succeed if the unread portion of the buffer matches the regular expression "something".
|
will succeed if the unread portion of the buffer matches the regular expression "something".
|
||||||
|
|
||||||
When Say succeeds, it fast forwards the gbytes.Buffer's read cursor to just after the succesful match.
|
When Say succeeds, it fast forwards the gbytes.Buffer's read cursor to just after the successful match.
|
||||||
Thus, subsequent calls to Say will only match against the unread portion of the buffer
|
Thus, subsequent calls to Say will only match against the unread portion of the buffer
|
||||||
|
|
||||||
Say pairs very well with Eventually. To assert that a buffer eventually receives data matching "[123]-star" within 3 seconds you can:
|
Say pairs very well with Eventually. To assert that a buffer eventually receives data matching "[123]-star" within 3 seconds you can:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 5
|
||||||
|
|
||||||
package gexec
|
package gexec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -66,7 +68,7 @@ func doBuild(gopath, packagePath string, env []string, args ...string) (compiled
|
||||||
|
|
||||||
executable := filepath.Join(tmpDir, path.Base(packagePath))
|
executable := filepath.Join(tmpDir, path.Base(packagePath))
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
executable = executable + ".exe"
|
executable += ".exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdArgs := append([]string{"build"}, args...)
|
cmdArgs := append([]string{"build"}, args...)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package gexec
|
package gexec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 1
|
||||||
|
|
||||||
package gexec
|
package gexec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -6,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PrefixedWriter wraps an io.Writer, emiting the passed in prefix at the beginning of each new line.
|
PrefixedWriter wraps an io.Writer, emitting the passed in prefix at the beginning of each new line.
|
||||||
This can be useful when running multiple gexec.Sessions concurrently - you can prefix the log output of each
|
This can be useful when running multiple gexec.Sessions concurrently - you can prefix the log output of each
|
||||||
session by passing in a PrefixedWriter:
|
session by passing in a PrefixedWriter:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
/*
|
/*
|
||||||
Package gexec provides support for testing external processes.
|
Package gexec provides support for testing external processes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// untested sections: 1
|
||||||
|
|
||||||
package gexec
|
package gexec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"github.com/onsi/gomega/types"
|
"github.com/onsi/gomega/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const GOMEGA_VERSION = "1.5.0"
|
const GOMEGA_VERSION = "1.7.0"
|
||||||
|
|
||||||
const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil.
|
const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil.
|
||||||
If you're using Ginkgo then you probably forgot to put your assertion in an It().
|
If you're using Ginkgo then you probably forgot to put your assertion in an It().
|
||||||
|
|
@ -155,7 +155,7 @@ func Expect(actual interface{}, extra ...interface{}) Assertion {
|
||||||
// ExpectWithOffset(1, "foo").To(Equal("foo"))
|
// ExpectWithOffset(1, "foo").To(Equal("foo"))
|
||||||
//
|
//
|
||||||
// Unlike `Expect` and `Ω`, `ExpectWithOffset` takes an additional integer argument
|
// Unlike `Expect` and `Ω`, `ExpectWithOffset` takes an additional integer argument
|
||||||
// this is used to modify the call-stack offset when computing line numbers.
|
// that is used to modify the call-stack offset when computing line numbers.
|
||||||
//
|
//
|
||||||
// This is most useful in helper functions that make assertions. If you want Gomega's
|
// This is most useful in helper functions that make assertions. If you want Gomega's
|
||||||
// error message to refer to the calling line in the test (as opposed to the line in the helper function)
|
// error message to refer to the calling line in the test (as opposed to the line in the helper function)
|
||||||
|
|
@ -242,7 +242,7 @@ func EventuallyWithOffset(offset int, actual interface{}, intervals ...interface
|
||||||
// assert that all other values are nil/zero.
|
// assert that all other values are nil/zero.
|
||||||
// This allows you to pass Consistently a function that returns a value and an error - a common pattern in Go.
|
// This allows you to pass Consistently a function that returns a value and an error - a common pattern in Go.
|
||||||
//
|
//
|
||||||
// Consistently is useful in cases where you want to assert that something *does not happen* over a period of tiem.
|
// Consistently is useful in cases where you want to assert that something *does not happen* over a period of time.
|
||||||
// For example, you want to assert that a goroutine does *not* send data down a channel. In this case, you could:
|
// For example, you want to assert that a goroutine does *not* send data down a channel. In this case, you could:
|
||||||
//
|
//
|
||||||
// Consistently(channel).ShouldNot(Receive())
|
// Consistently(channel).ShouldNot(Receive())
|
||||||
|
|
@ -280,7 +280,7 @@ func SetDefaultEventuallyPollingInterval(t time.Duration) {
|
||||||
defaultEventuallyPollingInterval = t
|
defaultEventuallyPollingInterval = t
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultConsistentlyDuration sets the default duration for Consistently. Consistently will verify that your condition is satsified for this long.
|
// SetDefaultConsistentlyDuration sets the default duration for Consistently. Consistently will verify that your condition is satisfied for this long.
|
||||||
func SetDefaultConsistentlyDuration(t time.Duration) {
|
func SetDefaultConsistentlyDuration(t time.Duration) {
|
||||||
defaultConsistentlyDuration = t
|
defaultConsistentlyDuration = t
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +320,7 @@ type GomegaAsyncAssertion = AsyncAssertion
|
||||||
// All methods take a variadic optionalDescription argument. This is passed on to fmt.Sprintf()
|
// All methods take a variadic optionalDescription argument. This is passed on to fmt.Sprintf()
|
||||||
// and is used to annotate failure messages.
|
// and is used to annotate failure messages.
|
||||||
//
|
//
|
||||||
// All methods return a bool that is true if hte assertion passed and false if it failed.
|
// All methods return a bool that is true if the assertion passed and false if it failed.
|
||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package asyncassertion
|
package asyncassertion
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,22 @@ func ContainElement(element interface{}) types.GomegaMatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BeElementOf succeeds if actual is contained in the passed in elements.
|
||||||
|
//BeElementOf() always uses Equal() to perform the match.
|
||||||
|
//When the passed in elements are comprised of a single element that is either an Array or Slice, BeElementOf() behaves
|
||||||
|
//as the reverse of ContainElement() that operates with Equal() to perform the match.
|
||||||
|
// Expect(2).Should(BeElementOf([]int{1, 2}))
|
||||||
|
// Expect(2).Should(BeElementOf([2]int{1, 2}))
|
||||||
|
//Otherwise, BeElementOf() provides a syntactic sugar for Or(Equal(_), Equal(_), ...):
|
||||||
|
// Expect(2).Should(BeElementOf(1, 2))
|
||||||
|
//
|
||||||
|
//Actual must be typed.
|
||||||
|
func BeElementOf(elements ...interface{}) types.GomegaMatcher {
|
||||||
|
return &matchers.BeElementOfMatcher{
|
||||||
|
Elements: elements,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//ConsistOf succeeds if actual contains precisely the elements passed into the matcher. The ordering of the elements does not matter.
|
//ConsistOf succeeds if actual contains precisely the elements passed into the matcher. The ordering of the elements does not matter.
|
||||||
//By default ConsistOf() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
|
//By default ConsistOf() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 5
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 5
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 3
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
// untested sections: 1
|
||||||
|
|
||||||
|
package matchers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/onsi/gomega/format"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BeElementOfMatcher struct {
|
||||||
|
Elements []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err error) {
|
||||||
|
if reflect.TypeOf(actual) == nil {
|
||||||
|
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 i := 0; i < length; i++ {
|
||||||
|
matcher := &EqualMatcher{Expected: valueAt(i)}
|
||||||
|
success, err := matcher.Match(actual)
|
||||||
|
if err != nil {
|
||||||
|
lastError = err
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if success {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, lastError
|
||||||
|
}
|
||||||
|
|
||||||
|
func (matcher *BeElementOfMatcher) FailureMessage(actual interface{}) (message string) {
|
||||||
|
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", matcher.Elements)
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import "github.com/onsi/gomega/format"
|
import "github.com/onsi/gomega/format"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 4
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 3
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 3
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 3
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -22,19 +24,21 @@ func (matcher *ContainElementMatcher) Match(actual interface{}) (success bool, e
|
||||||
}
|
}
|
||||||
|
|
||||||
value := reflect.ValueOf(actual)
|
value := reflect.ValueOf(actual)
|
||||||
var keys []reflect.Value
|
var valueAt func(int) interface{}
|
||||||
if isMap(actual) {
|
if isMap(actual) {
|
||||||
keys = value.MapKeys()
|
keys := value.MapKeys()
|
||||||
|
valueAt = func(i int) interface{} {
|
||||||
|
return value.MapIndex(keys[i]).Interface()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
valueAt = func(i int) interface{} {
|
||||||
|
return value.Index(i).Interface()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastError error
|
var lastError error
|
||||||
for i := 0; i < value.Len(); i++ {
|
for i := 0; i < value.Len(); i++ {
|
||||||
var success bool
|
success, err := elemMatcher.Match(valueAt(i))
|
||||||
var err error
|
|
||||||
if isMap(actual) {
|
|
||||||
success, err = elemMatcher.Match(value.MapIndex(keys[i]).Interface())
|
|
||||||
} else {
|
|
||||||
success, err = elemMatcher.Match(value.Index(i).Interface())
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lastError = err
|
lastError = err
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 6
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections:10
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 2
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 3
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// untested sections: 5
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package bipartitegraph
|
package bipartitegraph
|
||||||
|
|
||||||
import "errors"
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
import . "github.com/onsi/gomega/matchers/support/goraph/node"
|
import . "github.com/onsi/gomega/matchers/support/goraph/node"
|
||||||
|
|
@ -28,7 +27,7 @@ func NewBipartiteGraph(leftValues, rightValues []interface{}, neighbours func(in
|
||||||
for j, rightValue := range rightValues {
|
for j, rightValue := range rightValues {
|
||||||
neighbours, err := neighbours(leftValue, rightValue)
|
neighbours, err := neighbours(leftValue, rightValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(fmt.Sprintf("error determining adjacency for %v and %v: %s", leftValue, rightValue, err.Error()))
|
return nil, fmt.Errorf("error determining adjacency for %v and %v: %s", leftValue, rightValue, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if neighbours {
|
if neighbours {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ See the docs for Gomega for documentation on the matchers
|
||||||
|
|
||||||
http://onsi.github.io/gomega/
|
http://onsi.github.io/gomega/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// untested sections: 11
|
||||||
|
|
||||||
package matchers
|
package matchers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ github.com/onsi/ginkgo/internal/containernode
|
||||||
github.com/onsi/ginkgo/internal/leafnodes
|
github.com/onsi/ginkgo/internal/leafnodes
|
||||||
github.com/onsi/ginkgo/internal/spec
|
github.com/onsi/ginkgo/internal/spec
|
||||||
github.com/onsi/ginkgo/internal/specrunner
|
github.com/onsi/ginkgo/internal/specrunner
|
||||||
# github.com/onsi/gomega v1.5.0
|
# github.com/onsi/gomega v1.7.0
|
||||||
github.com/onsi/gomega
|
github.com/onsi/gomega
|
||||||
github.com/onsi/gomega/gexec
|
github.com/onsi/gomega/gexec
|
||||||
github.com/onsi/gomega/internal/assertion
|
github.com/onsi/gomega/internal/assertion
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue