File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,13 @@ import (
88)
99
1010func SpinWhile (name string , action func ()) error {
11- if isatty .IsTerminal (os .Stdout .Fd ()) {
11+ if ! isatty .IsTerminal (os .Stdout .Fd ()) {
12+ // No TTY available, just run the action without spinner
1213 action ()
13-
1414 return nil
1515 }
1616
17+ // TTY is available, use the spinner
1718 return spinner .New ().
1819 Title (name ).
1920 Action (action ).
Original file line number Diff line number Diff line change 1+ package io
2+
3+ import (
4+ "testing"
5+ )
6+
7+ func TestSpinWhileWithoutTTY (t * testing.T ) {
8+ // Test that SpinWhile works without TTY
9+ actionCalled := false
10+ err := SpinWhile ("Test action" , func () {
11+ actionCalled = true
12+ })
13+
14+ if err != nil {
15+ t .Errorf ("SpinWhile should not return error: %v" , err )
16+ }
17+
18+ if ! actionCalled {
19+ t .Error ("Action should have been called" )
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments