Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions progress/indicator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
14 changes: 7 additions & 7 deletions progress/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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]`),
Expand All @@ -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())
}
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion progress/tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestTracker_ETA(t *testing.T) {
timeDelayUnit := time.Millisecond
timeDelayUnit := time.Microsecond * 100
timeDelay := timeDelayUnit * 25

tracker := Tracker{}
Expand Down