From dbb20005902d8fba658f5cb9b7267715315e68e5 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 31 May 2016 09:09:06 +0000 Subject: [PATCH] Fix pkg/streamformatter.TestJSONFormatProgress The test was failing if the terminal column width is <= 110. Addendum to #23113 Signed-off-by: Akihiro Suda --- streamformatter/streamformatter_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/streamformatter/streamformatter_test.go b/streamformatter/streamformatter_test.go index 833db62..93ec90f 100644 --- a/streamformatter/streamformatter_test.go +++ b/streamformatter/streamformatter_test.go @@ -94,8 +94,12 @@ func TestJSONFormatProgress(t *testing.T) { // Compare the progress strings before the timeLeftBox expectedProgress := "[=========================> ] 15 B/30 B" - if !strings.HasPrefix(msg.ProgressMessage, expectedProgress) { - t.Fatalf("ProgressMessage without the timeLeftBox must be %s, got: %s", expectedProgress, msg.ProgressMessage) + // if terminal column is <= 110, expectedProgressShort is expected. + expectedProgressShort := " 15 B/30 B" + if !(strings.HasPrefix(msg.ProgressMessage, expectedProgress) || + strings.HasPrefix(msg.ProgressMessage, expectedProgressShort)) { + t.Fatalf("ProgressMessage without the timeLeftBox must be %s or %s, got: %s", + expectedProgress, expectedProgressShort, msg.ProgressMessage) } if !reflect.DeepEqual(msg.Progress, progress) {