Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
| ... | ... |
@@ -17,13 +17,22 @@ func TestProgress(t *testing.T) {
|
| 17 | 17 |
t.Fatalf("Expected empty string, got '%s'", jp.String())
|
| 18 | 18 |
} |
| 19 | 19 |
|
| 20 |
+ expected := " 1 B" |
|
| 20 | 21 |
jp2 := JSONProgress{Current: 1}
|
| 21 |
- if jp2.String() != " 1 B" {
|
|
| 22 |
- t.Fatalf("Expected ' 1 B', got '%s'", jp2.String())
|
|
| 22 |
+ if jp2.String() != expected {
|
|
| 23 |
+ t.Fatalf("Expected %q, got %q", expected, jp2.String())
|
|
| 23 | 24 |
} |
| 24 | 25 |
|
| 26 |
+ expected = "[=========================> ] 50 B/100 B" |
|
| 25 | 27 |
jp3 := JSONProgress{Current: 50, Total: 100}
|
| 26 |
- if jp3.String() != "[=========================> ] 50 B/100 B" {
|
|
| 27 |
- t.Fatalf("Expected '[=========================> ] 50 B/100 B', got '%s'", jp3.String())
|
|
| 28 |
+ if jp3.String() != expected {
|
|
| 29 |
+ t.Fatalf("Expected %q, got %q", expected, jp3.String())
|
|
| 30 |
+ } |
|
| 31 |
+ |
|
| 32 |
+ // this number can't be negetive gh#7136 |
|
| 33 |
+ expected = "[==============================================================>] 50 B/40 B" |
|
| 34 |
+ jp4 := JSONProgress{Current: 50, Total: 40}
|
|
| 35 |
+ if jp4.String() != expected {
|
|
| 36 |
+ t.Fatalf("Expected %q, got %q", expected, jp4.String())
|
|
| 28 | 37 |
} |
| 29 | 38 |
} |