TestAnimation_NoSpinnerOffTerminal verifies the production behavior that the thinking spinner does not start when stdout is not a terminal (pipe/CI): the message is recorded but no goroutine repaints into the stream.
(t *testing.T)
| 16 | // thinking spinner does not start when stdout is not a terminal (pipe/CI): |
| 17 | // the message is recorded but no goroutine repaints into the stream. |
| 18 | func TestAnimation_NoSpinnerOffTerminal(t *testing.T) { |
| 19 | t.Cleanup(func() { theme.SetProfile(theme.DetectProfile()) }) |
| 20 | theme.SetProfile(theme.ProfileNoTTY) |
| 21 | |
| 22 | am := NewAnimationManager() |
| 23 | am.ShowThinkingAnimation("pensando") |
| 24 | |
| 25 | am.mu.Lock() |
| 26 | running := am.isRunning |
| 27 | msg := am.currentMessage |
| 28 | am.mu.Unlock() |
| 29 | |
| 30 | assert.False(t, running, "no spinner goroutine off-terminal") |
| 31 | assert.Equal(t, "pensando", msg, "message is still recorded for non-animated surfaces") |
| 32 | |
| 33 | // Stop must be a safe no-op when nothing started. |
| 34 | am.StopThinkingAnimation() |
| 35 | } |
| 36 | |
| 37 | // TestAnimation_SuppressedDoesNotRun confirms explicit suppression (used by |
| 38 | // the unattended gateway) also prevents the goroutine even on a terminal. |
nothing calls this directly
no test coverage detected