Ver código fonte

Merge pull request #23120 from AkihiroSuda/fixStreamFormatter

Fix pkg/streamformatter.TestJSONFormatProgress
Alexander Morozov 9 anos atrás
pai
commit
2ca25302fe
1 arquivos alterados com 6 adições e 2 exclusões
  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) {