stretchr/testify

Diff is empty when lines are too long

Open

#746 aberto em 27 de mar. de 2019

Ver no GitHub
 (6 comments) (7 reactions) (0 assignees)Go (1.704 forks)batch import
help wanted

Métricas do repositório

Stars
 (25.958 stars)
Métricas de merge de PR
 (Mesclagem média 6d 15h) (2 fundiu PRs em 30d)

Description

On assert.Equal failures, if the diff has long lines (due to complicated structs), instead of showing something like

require.go:157:
                	Error Trace:	common_test.go:72
                	            				transactions_test.go:844
                	Error:      	Not equal:
					expected: ...
					actual: ...

					Diff:
					--- Expected
					+++ Actual
					<super long line...>
                	Test:       	TestTransactionsQueryFingerprint
                	Messages:   	Response does not match expected return

Currently the diff is completely cut off

require.go:157:
                	Error Trace:	common_test.go:72
                	            				transactions_test.go:844
                	Error:      	Not equal:
                	Test:       	TestTransactionsQueryFingerprint
                	Messages:   	Response does not match expected return

This makes testing hard to check which lines differed.

Upon inspecting, indentation formatting of diff lines is using bufio.Scanner which has a default MaxScanTokenSize (64K) and would not parse long lines: https://github.com/stretchr/testify/blob/master/assert/assertions.go#L201

Can be fixed by either changing from bufio.Scanner to bufio.Reader or truncating long lines up to the max token size (or even provide a config to change max). Thoughts?

Guia do colaborador