diff options
Diffstat (limited to 'internal/cli/timer_test.go')
| -rw-r--r-- | internal/cli/timer_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/cli/timer_test.go b/internal/cli/timer_test.go index 25f9618..32b9b8b 100644 --- a/internal/cli/timer_test.go +++ b/internal/cli/timer_test.go @@ -5,6 +5,7 @@ import ( "path/filepath" "strings" "testing" + "time" timrTimer "codeberg.org/snonux/timr/internal/timer" "codeberg.org/snonux/timr/internal/worktime" @@ -113,6 +114,32 @@ func TestTimerAutoWorktimeSync(t *testing.T) { } } +func TestTimerAutoWorktimeSyncIgnoresAlreadyLoggedIn(t *testing.T) { + setupTimerState(t) + + dbDir := t.TempDir() + if _, err := worktime.Login(dbDir, "host-auto", "work", time.Unix(100, 0), "seed"); err != nil { + t.Fatalf("seed Login() error = %v", err) + } + + cfgPath := writeWorkConfigWithAuto(t, dbDir, "host-auto", true) + out, err := runRootCommand("--config", cfgPath, "timer", "start") + if err != nil { + t.Fatalf("timer start error = %v (output: %q)", err, out) + } +} + +func TestTimerAutoWorktimeSyncIgnoresNotLoggedInOnStop(t *testing.T) { + setupTimerState(t) + + dbDir := t.TempDir() + cfgPath := writeWorkConfigWithAuto(t, dbDir, "host-auto", true) + out, err := runRootCommand("--config", cfgPath, "timer", "stop") + if err != nil { + t.Fatalf("timer stop error = %v (output: %q)", err, out) + } +} + func setupTimerState(t *testing.T) { t.Helper() |
