From 1bd7f7cb1681208c6a6a5b45b1874dc3f224cc9e Mon Sep 17 00:00:00 2001 From: Ben Kraft Date: Thu, 15 Apr 2021 15:43:46 -0700 Subject: [PATCH] put example-test verbose flag in right place --- generate/example_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/generate/example_test.go b/generate/example_test.go index 6f90c57..3b74949 100644 --- a/generate/example_test.go +++ b/generate/example_test.go @@ -39,9 +39,10 @@ func TestGenerateExample(t *testing.T) { } if !bytes.Equal(content, expectedContent) { - t.Errorf( - "diffs to %v:\n---actual---\n%v\n---expected---\n%v", - filename, string(content), string(expectedContent)) + t.Errorf("mismatch in %s", filename) + if testing.Verbose() { + t.Errorf("got:\n%s\nwant:\n%s\n", content, expectedContent) + } } } } @@ -61,9 +62,6 @@ func TestRunExample(t *testing.T) { got := strings.TrimSpace(string(out)) want := "benjaminjkraft is Ben Kraft created on 2009-08-03" if got != want { - t.Errorf("output incorrect") - if testing.Verbose() { - t.Errorf("got:\n%s\nwant:\n%s", got, want) - } + t.Errorf("output incorrect\ngot:\n%s\nwant:\n%s", got, want) } }