package migration

import (
	"testing"
)

func TestHasPendingMigrationInviteNilDB(t *testing.T) {
	ok, err := HasPendingMigrationInvite(t.Context(), nil, "user@example.com")
	if err != nil {
		t.Fatalf("HasPendingMigrationInvite() error = %v", err)
	}
	if ok {
		t.Fatal("expected false with nil db")
	}
}

func TestAuditProvisionByEmailEmpty(t *testing.T) {
	audit, err := AuditProvisionByEmail(t.Context(), nil, "")
	if err != nil {
		t.Fatalf("AuditProvisionByEmail() error = %v", err)
	}
	if audit.Users != 0 || audit.Mailboxes != 0 || audit.MailAccounts != 0 || audit.NCPrincipals != 0 {
		t.Fatalf("expected zero audit, got %#v", audit)
	}
}

func TestAuditProvisionByEmailNormalizesEmail(t *testing.T) {
	audit, err := AuditProvisionByEmail(t.Context(), nil, "  User@Example.COM  ")
	if err != nil {
		t.Fatalf("AuditProvisionByEmail() error = %v", err)
	}
	if audit.Users != 0 {
		t.Fatalf("expected zero users with nil db, got %d", audit.Users)
	}
}
