Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TestRestart - CrossOS Passing & More Consistent #125

Merged
merged 2 commits into from Dec 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 9 additions & 13 deletions spinner_test.go
Expand Up @@ -106,25 +106,21 @@ func TestStop(t *testing.T) {

// TestRestart will verify a spinner can be stopped and started again
func TestRestart(t *testing.T) {
s := New(CharSets[4], 50*time.Millisecond)
var out syncBuffer
s.Writer = &out
s, out := withOutput(CharSets[4], 40*time.Millisecond)

s.Start()
s.Color("cyan")
time.Sleep(200 * time.Millisecond)
time.Sleep(150 * time.Millisecond)
s.Restart()
time.Sleep(200 * time.Millisecond)
time.Sleep(158 * time.Millisecond)
s.Stop()
time.Sleep(50 * time.Millisecond)
out.Lock()
defer out.Unlock()
time.Sleep(10 * time.Millisecond)

result := out.Bytes()
first := result[:len(result)/2]
secnd := result[len(result)/2:]
if string(first) != string(secnd) {
t.Errorf("Expected ==, got \n%#v != \n%#v", first, secnd)
second := result[len(result)/2:]
if !bytes.Equal(first, second) {
t.Errorf("expected restart output to match initial output. got=%q want=%q", first, second)
}
s = nil
}

// TestHookFunctions will verify that hook functions works as expected
Expand Down