- 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
45 lines
885 B
Go
45 lines
885 B
Go
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())
|
|
}
|
|
}
|