"""
Config fail-fast: importing app.config with DATABASE_URL unset must raise.
"""

from __future__ import annotations

import importlib

import pytest


def test_database_url_required(monkeypatch):
    """Settings() with empty DATABASE_URL → RuntimeError at instantiation."""
    from app import config as app_config

    monkeypatch.setenv("DATABASE_URL", "")
    # Pass _env_file=None so a stray .env on disk can't satisfy the field.
    with pytest.raises(RuntimeError, match="DATABASE_URL is required"):
        app_config.Settings(_env_file=None, DATABASE_URL="")
