stretchr/testify

Diff is empty when lines are too long

Open

#746 ouverte le 27 mars 2019

Voir sur GitHub
 (6 commentaires) (7 réactions) (0 assignés)Go (1 704 forks)batch import
help wanted

Métriques du dépôt

Stars
 (25 958 stars)
Métriques de merge PR
 (Merge moyen 6j 15h) (2 PRs mergées en 30 j)

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?

Guide contributeur