package main import ( "strings" "testing" "time" "gogs.netdome.biz/paul/cheapo/internal/game" ) func mustParse(s string) time.Time { tt, err := time.Parse(time.RFC3339, s) if err != nil { panic(err) } return tt } func TestFormatGamesDefaultDate(t *testing.T) { t.Setenv("CHEAPO_CHATTO_OUTPUT_DATE_FORMAT", "") games := []game.Game{{Title: "G", Store: "epic", URL: "u", Kind: "free-now", EndDate: mustParse("2026-11-02T00:00:00Z")}} out := formatGames(games, "") if !strings.Contains(out, "until 02.11.2026") { t.Fatalf("expected compact date, got:\n%s", out) } } func TestFormatGamesCustomDate(t *testing.T) { t.Setenv("CHEAPO_CHATTO_OUTPUT_DATE_FORMAT", "2006-01-02") games := []game.Game{{Title: "G", Store: "epic", URL: "u", Kind: "free-now", EndDate: mustParse("2026-11-02T00:00:00Z")}} out := formatGames(games, "") if !strings.Contains(out, "until 2026-11-02") { t.Fatalf("expected ISO date, got:\n%s", out) } }