diff --git a/progress/indicator_test.go b/progress/indicator_test.go index 5494208..53e3c44 100644 --- a/progress/indicator_test.go +++ b/progress/indicator_test.go @@ -46,13 +46,13 @@ func TestIndeterminateIndicatorDominoes(t *testing.T) { } out := strings.Builder{} - f := IndeterminateIndicatorDominoes(time.Millisecond * 10) + f := IndeterminateIndicatorDominoes(time.Microsecond * 10) for idx, expectedText := range expectedTexts { actual := f(maxLen) assert.Equal(t, 0, actual.Position, fmt.Sprintf("expectedTexts[%d]", idx)) assert.Equal(t, expectedText, actual.Text, fmt.Sprintf("expectedTexts[%d]", idx)) out.WriteString(fmt.Sprintf("`%v`,\n", actual.Text)) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Microsecond * 10) } if t.Failed() { fmt.Println(out.String()) @@ -101,13 +101,13 @@ func TestIndeterminateIndicatorColoredDominoes(t *testing.T) { } out := strings.Builder{} - f := IndeterminateIndicatorColoredDominoes(time.Millisecond*10, text.FgHiGreen, text.FgHiBlack) + f := IndeterminateIndicatorColoredDominoes(time.Microsecond*10, text.FgHiGreen, text.FgHiBlack) for idx, expectedText := range expectedTexts { actual := f(maxLen) assert.Equal(t, 0, actual.Position, fmt.Sprintf("expectedTexts[%d]", idx)) assert.Equal(t, expectedText, actual.Text, fmt.Sprintf("expectedTexts[%d]", idx)) out.WriteString(fmt.Sprintf("`%v`,\n", actual.Text)) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Microsecond * 10) } if t.Failed() { fmt.Println(out.String()) @@ -122,11 +122,11 @@ func TestIndeterminateIndicatorMovingBackAndForth(t *testing.T) { 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, } - f := IndeterminateIndicatorMovingBackAndForth(indicator, time.Millisecond*10) + f := IndeterminateIndicatorMovingBackAndForth(indicator, time.Microsecond*10) for idx, expectedPosition := range expectedPositions { actual := f(maxLen) assert.Equal(t, expectedPosition, actual.Position, fmt.Sprintf("expectedPositions[%d]", idx)) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Microsecond * 10) } } @@ -183,11 +183,11 @@ func TestIndeterminateIndicatorMovingLeftToRight(t *testing.T) { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, } - f := IndeterminateIndicatorMovingLeftToRight(indicator, time.Millisecond*10) + f := IndeterminateIndicatorMovingLeftToRight(indicator, time.Microsecond*10) for idx, expectedPosition := range expectedPositions { actual := f(maxLen) assert.Equal(t, expectedPosition, actual.Position, fmt.Sprintf("expectedPositions[%d]", idx)) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Microsecond * 10) } } @@ -244,11 +244,11 @@ func TestIndeterminateIndicatorMovingRightToLeft(t *testing.T) { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, } - f := IndeterminateIndicatorMovingRightToLeft(indicator, time.Millisecond*10) + f := IndeterminateIndicatorMovingRightToLeft(indicator, time.Microsecond*10) for idx, expectedPosition := range expectedPositions { actual := f(maxLen) assert.Equal(t, expectedPosition, actual.Position, fmt.Sprintf("expectedPositions[%d]", idx)) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Microsecond * 10) } } @@ -331,12 +331,12 @@ func TestIndeterminateIndicatorPacMan(t *testing.T) { } out := strings.Builder{} - f := IndeterminateIndicatorPacMan(time.Millisecond * 10) + f := IndeterminateIndicatorPacMan(time.Microsecond * 10) for idx, expectedText := range expectedTexts { actual := f(maxLen) assert.Equal(t, expectedText, actual.Text, fmt.Sprintf("expectedTexts[%d]", idx)) out.WriteString(fmt.Sprintf("%#v,\n", actual.Text)) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Microsecond * 10) } if t.Failed() { fmt.Println(out.String()) @@ -385,12 +385,12 @@ func TestIndeterminateIndicatorPacManChomp(t *testing.T) { } out := strings.Builder{} - f := IndeterminateIndicatorPacManChomp(time.Millisecond * 10) + f := IndeterminateIndicatorPacManChomp(time.Microsecond * 10) for idx, expectedText := range expectedTexts { actual := f(maxLen) assert.Equal(t, expectedText, actual.Text, fmt.Sprintf("expectedTexts[%d]", idx)) out.WriteString(fmt.Sprintf("%#v,\n", actual.Text)) - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Microsecond * 10) } if t.Failed() { fmt.Println(out.String()) diff --git a/progress/render_test.go b/progress/render_test.go index f74e6aa..2b6afa5 100644 --- a/progress/render_test.go +++ b/progress/render_test.go @@ -12,9 +12,9 @@ import ( ) var ( - trackerIncrementInterval = time.Millisecond * 20 - renderUpdateFrequency = time.Millisecond * 10 - renderWaitTime = time.Millisecond * 20 + trackerIncrementInterval = time.Millisecond * 2 + renderUpdateFrequency = time.Microsecond * 500 + renderWaitTime = time.Millisecond * 5 ) type outputWriter struct { @@ -343,7 +343,7 @@ func TestProgress_RenderNeverStarted(t *testing.T) { time.Sleep(renderWaitTime) tr.MarkAsDone() pw.Stop() - time.Sleep(time.Second) + time.Sleep(renderWaitTime) expectedOutPatterns := []*regexp.Regexp{ regexp.MustCompile(`\s*\.\.\. {2}\?\?\? {2}\[\.{23}] \[0 in 0s]`), @@ -365,9 +365,9 @@ func TestProgress_RenderNothing(t *testing.T) { pw.SetOutputWriter(&renderOutput) go pw.Render() - time.Sleep(time.Second) + time.Sleep(renderWaitTime) pw.Stop() - time.Sleep(time.Second) + time.Sleep(renderWaitTime) assert.Empty(t, renderOutput.String()) } @@ -790,7 +790,7 @@ func TestProgress_RenderSomeTrackers_WithOverallTracker_WithSpeedAndSpeedOverall regexp.MustCompile(`Calculating Total # 1 \.\.\. done! \[\d+\.\d+K in [\d.]+ms; \d+\.\d+K/s]`), regexp.MustCompile(`Downloading File # 2 \.\.\. done! \[\d+\.\d+KB in [\d.]+ms; \d+\.\d+KB/s]`), regexp.MustCompile(`Transferring Amount # 3 \.\.\. done! \[\$\d+\.\d+K in [\d.]+ms; \$\d+\.\d+K/s]`), - regexp.MustCompile(`\[[.#]+] \[[\d.ms]+; ~ETA: [\d.ms]+]`), + regexp.MustCompile(`\[[.#]+] \[[\d.ms]+; ~ETA: [\d.ms]+(; [\d.]+[\w/]+)?]`), regexp.MustCompile(`some information about something that happened at \d\d\d\d`), } out := renderOutput.String() diff --git a/progress/tracker_test.go b/progress/tracker_test.go index 16d4dce..b6d13b5 100644 --- a/progress/tracker_test.go +++ b/progress/tracker_test.go @@ -8,7 +8,7 @@ import ( ) func TestTracker_ETA(t *testing.T) { - timeDelayUnit := time.Millisecond + timeDelayUnit := time.Microsecond * 100 timeDelay := timeDelayUnit * 25 tracker := Tracker{}