package mail import "testing" func TestNormalizeIdempotencyKey(t *testing.T) { t.Run("empty allowed", func(t *testing.T) { key, ok := normalizeIdempotencyKey("") if !ok || key != "" { t.Fatalf("got %q ok=%v", key, ok) } }) t.Run("valid", func(t *testing.T) { key, ok := normalizeIdempotencyKey(" send-abc-123_456 ") if !ok || key != "send-abc-123_456" { t.Fatalf("got %q ok=%v", key, ok) } }) t.Run("too short", func(t *testing.T) { _, ok := normalizeIdempotencyKey("short") if ok { t.Fatal("expected invalid") } }) t.Run("invalid chars", func(t *testing.T) { _, ok := normalizeIdempotencyKey("bad key with spaces!!!!") if ok { t.Fatal("expected invalid") } }) }