summaryrefslogtreecommitdiff
path: root/internal/cli/work_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli/work_test.go')
-rw-r--r--internal/cli/work_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/cli/work_test.go b/internal/cli/work_test.go
index 9621bfb..2be0231 100644
--- a/internal/cli/work_test.go
+++ b/internal/cli/work_test.go
@@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"testing"
+ "time"
timrTimer "codeberg.org/snonux/timr/internal/timer"
)
@@ -108,6 +109,28 @@ func TestWorkLoginLogoutWithTimerFlags(t *testing.T) {
}
}
+func TestParseImportDateFallbackLayout(t *testing.T) {
+ parsed, err := parseImportDate("06.01.2026")
+ if err != nil {
+ t.Fatalf("parseImportDate() error = %v", err)
+ }
+
+ expected := time.Date(2026, 1, 6, 0, 0, 0, 0, time.Local)
+ if parsed.Year() != expected.Year() || parsed.Month() != expected.Month() || parsed.Day() != expected.Day() {
+ t.Fatalf("parsed date = %v, want %v", parsed, expected)
+ }
+}
+
+func TestParseImportDateIncludesUnderlyingParseError(t *testing.T) {
+ _, err := parseImportDate("not-a-date")
+ if err == nil {
+ t.Fatal("parseImportDate() error = nil, want error")
+ }
+ if !strings.Contains(err.Error(), "unsupported import date") {
+ t.Fatalf("parseImportDate() error = %v, want unsupported import date context", err)
+ }
+}
+
func writeWorkConfig(t *testing.T, dbDir, host string) string {
return writeWorkConfigWithAuto(t, dbDir, host, false)
}