Skip to content

Commit

Permalink
tweak truncation message
Browse files Browse the repository at this point in the history
  • Loading branch information
onsi committed Mar 18, 2021
1 parent cc80b6f commit 3360b8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
var MaxDepth = uint(10)

// MaxLength of the string representation of an object.
// If MaxLength is set to 0, the Object will not be truncted.
// If MaxLength is set to 0, the Object will not be truncated.
var MaxLength = 4000

/*
Expand Down Expand Up @@ -171,8 +171,7 @@ func findFirstMismatch(a, b string) int {
return 0
}

const truncateHelpText = `the very very long object here that goes on forever and ever but then gets trunc....
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.
Expand All @@ -191,7 +190,7 @@ func truncateLongStrings(s string) string {
break
}

sb.WriteString("\n")
sb.WriteString("...\n")
sb.WriteString(truncateHelpText)

return sb.String()
Expand Down
2 changes: 1 addition & 1 deletion format/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var _ = Describe("Format", func() {

It("should print out an indented formatted representation of the value and the message, and trucate it when too long", func() {
tooLong := strings.Repeat("s", MaxLength+1)
tooLongResult := strings.Repeat("s", MaxLength) + "\n" + TruncatedHelpText()
tooLongResult := strings.Repeat("s", MaxLength) + "...\n" + TruncatedHelpText()
Expect(Message(tooLong, "to be truncated")).Should(Equal("Expected\n <string>: " + tooLongResult + "\nto be truncated"))
})

Expand Down

0 comments on commit 3360b8c

Please sign in to comment.