summaryrefslogtreecommitdiff
path: root/vendor/github.com/onsi/gomega/format
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2019-09-30 12:44:47 +0000
committerValentin Rothberg <rothberg@redhat.com>2019-10-01 17:14:55 +0200
commit6c72b5c5926fdaed67936f0b1c6f948e3bf5c441 (patch)
tree63d66b30f322695f79acf8650532a89d705d2e79 /vendor/github.com/onsi/gomega/format
parentd7eba026876e4a6a362464dcf08fe6757ebedd1a (diff)
downloadpodman-6c72b5c5926fdaed67936f0b1c6f948e3bf5c441.tar.gz
podman-6c72b5c5926fdaed67936f0b1c6f948e3bf5c441.tar.bz2
podman-6c72b5c5926fdaed67936f0b1c6f948e3bf5c441.zip
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>
Diffstat (limited to 'vendor/github.com/onsi/gomega/format')
-rw-r--r--vendor/github.com/onsi/gomega/format/format.go37
1 files changed, 26 insertions, 11 deletions
diff --git a/vendor/github.com/onsi/gomega/format/format.go b/vendor/github.com/onsi/gomega/format/format.go
index 6559525f1..fae25adce 100644
--- a/vendor/github.com/onsi/gomega/format/format.go
+++ b/vendor/github.com/onsi/gomega/format/format.go
@@ -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)
}