(t *testing.T)
| 588 | } |
| 589 | |
| 590 | func TestOptionSetElapsedTime(t *testing.T) { |
| 591 | buf := strings.Builder{} |
| 592 | bar := NewOptions( |
| 593 | 10, |
| 594 | OptionSetElapsedTime(false), |
| 595 | OptionSetPredictTime(false), |
| 596 | OptionSetWidth(10), |
| 597 | OptionSetWriter(&buf), |
| 598 | ) |
| 599 | |
| 600 | _ = bar.Add(2) |
| 601 | result := strings.TrimSpace(buf.String()) |
| 602 | expect := "20% |██ |" |
| 603 | |
| 604 | if result != expect { |
| 605 | t.Errorf("Render miss-match\nResult: '%s'\nExpect: '%s'\n%+v", result, expect, bar) |
| 606 | } |
| 607 | |
| 608 | bar.Reset() |
| 609 | bar.config.elapsedTime = true |
| 610 | buf.Reset() |
| 611 | |
| 612 | _ = bar.Add(7) |
| 613 | result = strings.TrimSpace(buf.String()) |
| 614 | expect = "70% |███████ | [0s]" |
| 615 | |
| 616 | if result != expect { |
| 617 | t.Errorf("Render miss-match\nResult: '%s'\nExpect: '%s'\n%+v", result, expect, bar) |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | func TestShowElapsedTimeOnFinish(t *testing.T) { |
| 622 | buf := strings.Builder{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…