summaryrefslogtreecommitdiff
path: root/internal/askcli/command_watch.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/askcli/command_watch.go')
-rw-r--r--internal/askcli/command_watch.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/askcli/command_watch.go b/internal/askcli/command_watch.go
index 8d8e35f..0e0a678 100644
--- a/internal/askcli/command_watch.go
+++ b/internal/askcli/command_watch.go
@@ -30,7 +30,10 @@ func (t realWatchTicker) Stop() {
t.ticker.Stop()
}
-var newWatchTicker = func(interval time.Duration) watchTicker {
+// newRealWatchTicker is the default watchTicker factory wired into a
+// Dispatcher by NewDispatcher. It is injected as Dispatcher.newTicker so tests
+// can substitute a fake ticker instead of mutating package state.
+func newRealWatchTicker(interval time.Duration) watchTicker {
return realWatchTicker{ticker: time.NewTicker(interval)}
}
@@ -63,7 +66,7 @@ func (d *Dispatcher) handleWatch(ctx context.Context, args []string, stdout, std
return 1, nil
}
- ticker := newWatchTicker(watchInterval)
+ ticker := d.newTicker(watchInterval)
defer ticker.Stop()
var lastOutput []byte