TestOptionSetPredictTime ensures that when predict time is turned off, the progress bar is showing the total steps completed of the given max, otherwise the predicted time in seconds is specified.
(t *testing.T)
| 533 | // bar is showing the total steps completed of the given max, otherwise the predicted |
| 534 | // time in seconds is specified. |
| 535 | func TestOptionSetPredictTime(t *testing.T) { |
| 536 | buf := strings.Builder{} |
| 537 | bar := NewOptions( |
| 538 | 10, |
| 539 | OptionSetPredictTime(false), |
| 540 | OptionSetWidth(10), |
| 541 | OptionSetWriter(&buf), |
| 542 | ) |
| 543 | |
| 544 | _ = bar.Add(2) |
| 545 | result := strings.TrimSpace(buf.String()) |
| 546 | expect := "20% |██ |" |
| 547 | |
| 548 | if result != expect { |
| 549 | t.Errorf("Render miss-match\nResult: '%s'\nExpect: '%s'\n%+v", result, expect, bar) |
| 550 | } |
| 551 | |
| 552 | bar.Reset() |
| 553 | bar.config.predictTime = true |
| 554 | buf.Reset() |
| 555 | |
| 556 | _ = bar.Add(7) |
| 557 | result = strings.TrimSpace(buf.String()) |
| 558 | expect = "70% |███████ | [0s:0s]" |
| 559 | |
| 560 | if result != expect { |
| 561 | t.Errorf("Render miss-match\nResult: '%s'\nExpect: '%s'\n%+v", result, expect, bar) |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | func TestOptionSetElapsedTime_spinner(t *testing.T) { |
| 566 | buf := strings.Builder{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…