package handlers

import (
	"testing"
	"time"
)

func TestParseAuditTimestamp_RFC3339(t *testing.T) {
	got, err := parseAuditTimestamp("2026-04-29T14:35:06Z")
	if err != nil {
		t.Fatalf("parse RFC3339: %v", err)
	}
	want := time.Date(2026, 4, 29, 14, 35, 6, 0, time.UTC)
	if !got.Equal(want) {
		t.Errorf("got %v, want %v", got, want)
	}
}

func TestParseAuditTimestamp_DateOnly(t *testing.T) {
	got, err := parseAuditTimestamp("2026-04-29")
	if err != nil {
		t.Fatalf("parse date-only: %v", err)
	}
	want := time.Date(2026, 4, 29, 0, 0, 0, 0, time.UTC)
	if !got.Equal(want) {
		t.Errorf("got %v, want %v", got, want)
	}
}

func TestParseAuditTimestamp_Invalid(t *testing.T) {
	if _, err := parseAuditTimestamp("not-a-time"); err == nil {
		t.Error("expected error for malformed timestamp")
	}
}
