From 3360b8c16fc5d11e1f5435f14b516708f18caf9d Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Wed, 17 Mar 2021 19:19:24 -0600 Subject: [PATCH] tweak truncation message --- format/format.go | 7 +++---- format/format_test.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/format/format.go b/format/format.go index 75f9be1a3..6e78c391d 100644 --- a/format/format.go +++ b/format/format.go @@ -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 /* @@ -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. @@ -191,7 +190,7 @@ func truncateLongStrings(s string) string { break } - sb.WriteString("\n") + sb.WriteString("...\n") sb.WriteString(truncateHelpText) return sb.String() diff --git a/format/format_test.go b/format/format_test.go index 1c0bf4d74..967349d2d 100644 --- a/format/format_test.go +++ b/format/format_test.go @@ -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 : " + tooLongResult + "\nto be truncated")) })