package audit

import (
	"testing"
	"time"
)

func TestAuditPartitionMonth(t *testing.T) {
	month, ok := auditPartitionMonth("audit_events_202608")
	if !ok || month.Format("2006-01-02") != "2026-08-01" {
		t.Fatalf("unexpected month: %v %v", month, ok)
	}
	if _, ok := auditPartitionMonth("audit_events_default"); ok {
		t.Fatal("default partition must not parse as a monthly partition")
	}
}

func TestMonthStartUsesUTC(t *testing.T) {
	value := time.Date(2026, 8, 31, 23, 0, 0, 0, time.FixedZone("UTC-2", -2*3600))
	if got := monthStart(value); got.Format(time.RFC3339) != "2026-09-01T00:00:00Z" {
		t.Fatalf("unexpected UTC month start: %s", got)
	}
}
