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:
dependabot-preview[bot]
2019-09-30 12:44:47 +00:00
committed by Valentin Rothberg
parent d7eba02687
commit 6c72b5c592
40 changed files with 218 additions and 32 deletions

View File

@ -4,6 +4,7 @@ go:
- 1.10.x
- 1.11.x
- 1.12.x
- gotip
env:
- GO111MODULE=on

View File

@ -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
### Features

View File

@ -1,6 +1,9 @@
/*
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
import (
@ -33,7 +36,15 @@ var PrintContextObjects = false
// TruncatedDiff choose if we should display a truncated pretty diff or not
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
type Ctx interface {
Deadline() (deadline time.Time, ok bool)
@ -58,7 +69,7 @@ Generates a formatted matcher success/failure message of the form:
<message>
<pretty printed expected>
If expected is omited, then the message looks like:
If expected is omitted, then the message looks like:
Expected
<pretty printed actual>
@ -85,7 +96,7 @@ to equal |
*/
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)
formattedActual := truncateAndFormat(actual, diffPoint)
formattedExpected := truncateAndFormat(expected, diffPoint)
@ -97,14 +108,23 @@ func MessageWithDiff(actual, message, expected string) string {
padding := strings.Repeat(" ", spaceFromMessageToActual+spacesBeforeFormattedMismatch) + "|"
return Message(formattedActual, message+padding, formattedExpected)
}
actual = escapedWithGoSyntax(actual)
expected = escapedWithGoSyntax(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 {
leftPadding := `...`
rightPadding := `...`
start := index - charactersAroundMismatchToInclude
start := index - int(CharactersAroundMismatchToInclude)
if start < 0 {
start = 0
leftPadding = ""
@ -112,7 +132,7 @@ func truncateAndFormat(str string, index int) string {
// slice index must include the mis-matched character
lengthOfMismatchedCharacter := 1
end := index + charactersAroundMismatchToInclude + lengthOfMismatchedCharacter
end := index + int(CharactersAroundMismatchToInclude) + lengthOfMismatchedCharacter
if end > len(str) {
end = len(str)
rightPadding = ""
@ -141,11 +161,6 @@ func findFirstMismatch(a, b string) int {
return 0
}
const (
truncateThreshold = 50
charactersAroundMismatchToInclude = 5
)
/*
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 {
return fmt.Sprintf("%q", object)
}

View File

@ -1,3 +1,5 @@
// untested sections: 1
package gbytes
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".
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
Say pairs very well with Eventually. To assert that a buffer eventually receives data matching "[123]-star" within 3 seconds you can:

View File

@ -1,3 +1,5 @@
// untested sections: 5
package gexec
import (
@ -66,7 +68,7 @@ func doBuild(gopath, packagePath string, env []string, args ...string) (compiled
executable := filepath.Join(tmpDir, path.Base(packagePath))
if runtime.GOOS == "windows" {
executable = executable + ".exe"
executable += ".exe"
}
cmdArgs := append([]string{"build"}, args...)

View File

@ -1,3 +1,5 @@
// untested sections: 2
package gexec
import (

View File

@ -1,3 +1,5 @@
// untested sections: 1
package gexec
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
session by passing in a PrefixedWriter:

View File

@ -1,6 +1,9 @@
/*
Package gexec provides support for testing external processes.
*/
// untested sections: 1
package gexec
import (

View File

@ -24,7 +24,7 @@ import (
"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.
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"))
//
// 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
// 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.
// 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:
//
// Consistently(channel).ShouldNot(Receive())
@ -280,7 +280,7 @@ func SetDefaultEventuallyPollingInterval(t time.Duration) {
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) {
defaultConsistentlyDuration = t
}
@ -320,7 +320,7 @@ type GomegaAsyncAssertion = AsyncAssertion
// 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 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:
//

View File

@ -1,3 +1,5 @@
// untested sections: 2
package asyncassertion
import (

View File

@ -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.
//By default ConsistOf() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
//

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 5
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 5
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 3
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -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)
}

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import "github.com/onsi/gomega/format"

View File

@ -1,3 +1,5 @@
// untested sections: 4
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 3
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 3
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 3
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (
@ -22,19 +24,21 @@ func (matcher *ContainElementMatcher) Match(actual interface{}) (success bool, e
}
value := reflect.ValueOf(actual)
var keys []reflect.Value
var valueAt func(int) interface{}
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
for i := 0; i < value.Len(); i++ {
var success bool
var err error
if isMap(actual) {
success, err = elemMatcher.Match(value.MapIndex(keys[i]).Interface())
} else {
success, err = elemMatcher.Match(value.Index(i).Interface())
}
success, err := elemMatcher.Match(valueAt(i))
if err != nil {
lastError = err
continue

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 6
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections:10
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 2
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 3
package matchers
import (

View File

@ -1,3 +1,5 @@
// untested sections: 5
package matchers
import (

View File

@ -1,6 +1,5 @@
package bipartitegraph
import "errors"
import "fmt"
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 {
neighbours, err := neighbours(leftValue, rightValue)
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 {

View File

@ -6,6 +6,9 @@ See the docs for Gomega for documentation on the matchers
http://onsi.github.io/gomega/
*/
// untested sections: 11
package matchers
import (