diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-03 23:10:26 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-03 23:10:26 +0200 |
| commit | e96b0b370bcdd55ad2d5b20187e4bbae78785ff2 (patch) | |
| tree | 2475df7fb9119a3f1db95f54f9f7e718d65324b6 /internal/cli/timer_test.go | |
| parent | 28920ad225992386069d8513d0cf097dd50daeef (diff) | |
Task 352: integrate timer and worktime login sync
Diffstat (limited to 'internal/cli/timer_test.go')
| -rw-r--r-- | internal/cli/timer_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/cli/timer_test.go b/internal/cli/timer_test.go index dead994..25f9618 100644 --- a/internal/cli/timer_test.go +++ b/internal/cli/timer_test.go @@ -7,6 +7,7 @@ import ( "testing" timrTimer "codeberg.org/snonux/timr/internal/timer" + "codeberg.org/snonux/timr/internal/worktime" ) func TestTimerStartAndStopCommands(t *testing.T) { @@ -73,6 +74,45 @@ func TestTimerStatusFlagConflict(t *testing.T) { } } +func TestTimerAutoWorktimeSync(t *testing.T) { + setupTimerState(t) + + dbDir := t.TempDir() + 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) + } + out, err = runRootCommand("--config", cfgPath, "timer", "stop") + if err != nil { + t.Fatalf("timer stop error = %v (output: %q)", err, out) + } + + entries, err := worktime.LoadAll(dbDir) + if err != nil { + t.Fatalf("LoadAll() error = %v", err) + } + + var hasLogin bool + var hasLogout bool + for _, entry := range entries { + if entry.What != "work" { + continue + } + if entry.Action == "login" { + hasLogin = true + } + if entry.Action == "logout" { + hasLogout = true + } + } + + if !hasLogin || !hasLogout { + t.Fatalf("auto worktime sync missing login/logout entries: %+v", entries) + } +} + func setupTimerState(t *testing.T) { t.Helper() |
