Browse code

Fix pkg/streamformatter.TestJSONFormatProgress

The test was failing if the terminal column width is <= 110.

Addendum to #23113

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>

Akihiro Suda authored on 2016/05/31 18:09:06
Showing 1 changed files
... ...
@@ -94,8 +94,12 @@ func TestJSONFormatProgress(t *testing.T) {
94 94
 
95 95
 	// Compare the progress strings before the timeLeftBox
96 96
 	expectedProgress := "[=========================>                         ]     15 B/30 B"
97
-	if !strings.HasPrefix(msg.ProgressMessage, expectedProgress) {
98
-		t.Fatalf("ProgressMessage without the timeLeftBox must be %s, got: %s", expectedProgress, msg.ProgressMessage)
97
+	// if terminal column is <= 110, expectedProgressShort is expected.
98
+	expectedProgressShort := "    15 B/30 B"
99
+	if !(strings.HasPrefix(msg.ProgressMessage, expectedProgress) ||
100
+		strings.HasPrefix(msg.ProgressMessage, expectedProgressShort)) {
101
+		t.Fatalf("ProgressMessage without the timeLeftBox must be %s or %s, got: %s",
102
+			expectedProgress, expectedProgressShort, msg.ProgressMessage)
99 103
 	}
100 104
 
101 105
 	if !reflect.DeepEqual(msg.Progress, progress) {