feat(04-01): add Notifier interface and FocusTimer
- Notifier interface with ExecNotifier (notify-send) and NullNotifier - FocusTimer thread-safe with Set/IsActive/Remaining - shortName helper for session display names - Full test coverage for all components
This commit is contained in:
44
focus_test.go
Normal file
44
focus_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestFocusTimer_Set(t *testing.T) {
|
||||
var ft FocusTimer
|
||||
ft.Set(30 * time.Minute)
|
||||
if !ft.IsActive() {
|
||||
t.Error("IsActive() = false after Set(30min), want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFocusTimer_Expired(t *testing.T) {
|
||||
var ft FocusTimer
|
||||
ft.Set(0)
|
||||
if ft.IsActive() {
|
||||
t.Error("IsActive() = true after Set(0), want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFocusTimer_Remaining(t *testing.T) {
|
||||
var ft FocusTimer
|
||||
ft.Set(30 * time.Minute)
|
||||
rem := ft.Remaining()
|
||||
if rem <= 0 {
|
||||
t.Errorf("Remaining() = %v, want > 0", rem)
|
||||
}
|
||||
if rem > 30*time.Minute {
|
||||
t.Errorf("Remaining() = %v, want <= 30min", rem)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFocusTimer_ZeroValue(t *testing.T) {
|
||||
var ft FocusTimer
|
||||
if ft.IsActive() {
|
||||
t.Error("zero-value FocusTimer IsActive() = true, want false")
|
||||
}
|
||||
if ft.Remaining() != 0 {
|
||||
t.Errorf("zero-value Remaining() = %v, want 0", ft.Remaining())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user