浏览代码

Merge pull request #23120 from AkihiroSuda/fixStreamFormatter

Fix pkg/streamformatter.TestJSONFormatProgress
Alexander Morozov 9 年之前
父节点
当前提交
2ca25302fe
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      pkg/streamformatter/streamformatter_test.go

+ 6 - 2
pkg/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) {