fix(config): align Settings and alembic/env.py database_url defaults to spec-required ~/.cleveragents/cleveragents.db
CI / lint (pull_request) Successful in 20s
CI / typecheck (pull_request) Successful in 46s
CI / quality (pull_request) Successful in 44s
CI / security (pull_request) Successful in 52s
CI / build (pull_request) Successful in 24s
CI / helm (pull_request) Successful in 22s
CI / unit_tests (pull_request) Successful in 6m37s
CI / e2e_tests (pull_request) Successful in 17m48s
CI / integration_tests (pull_request) Successful in 22m31s
CI / docker (pull_request) Successful in 1m24s
CI / coverage (pull_request) Successful in 10m26s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 56m45s

- Fix Settings.database_url default from relative 'sqlite:///cleveragents.db'
  to absolute 'sqlite:////home/<user>/.cleveragents/cleveragents.db' using
  Path.home() / '.cleveragents' / 'cleveragents.db'
- Fix test_database_url default similarly to use ~/.cleveragents/cleveragents_test.db
- Fix alembic/env.py fallback default from Path.cwd() / '.cleveragents' / 'db.sqlite'
  to Path.home() / '.cleveragents' / 'cleveragents.db' (matching Settings)
- Both Settings and alembic/env.py now resolve to the same absolute path
- CLEVERAGENTS_DATABASE_URL env var override still works correctly in both
- Update coverage_boost_steps.py assertions to match new correct defaults
- Add 3 new Behave scenarios covering correct database_url default and env var override

ISSUES CLOSED: #2871
This commit is contained in:
2026-04-05 08:07:12 +00:00
parent 1411adfed3
commit 0d4a47f3c0
5 changed files with 87 additions and 6 deletions
+50
View File
@@ -650,3 +650,53 @@ def step_singleton_instances_should_be_different(context: Context) -> None:
def step_singleton_environment_should_be(context: Context, expected: str) -> None:
"""Assert the latest singleton reflects the current environment value."""
assert context.settings.environment == expected
@given('"{key}" is not set')
def step_env_var_not_set(context: Context, key: str) -> None:
"""Ensure a specific environment variable is not set."""
os.environ.pop(key, None)
if not hasattr(context, "env_vars_to_clean"):
context.env_vars_to_clean = []
# Track it so teardown knows to clean it if it gets set later
context.env_vars_to_clean.append(key)
@then('the database URL should point to "~/.cleveragents/cleveragents.db"')
def step_database_url_points_to_home(context: Context) -> None:
"""Verify the database URL resolves to the spec-required home directory path."""
expected_path = Path.home() / ".cleveragents" / "cleveragents.db"
url = context.settings.database_url
assert str(expected_path) in url, (
f"Expected database URL to contain '{expected_path}', got: {url}"
)
@then('the database URL should start with "{prefix}"')
def step_database_url_starts_with(context: Context, prefix: str) -> None:
"""Verify the database URL starts with the given prefix."""
url = context.settings.database_url
assert url.startswith(prefix), (
f"Expected database URL to start with '{prefix}', got: {url}"
)
@then('the database URL should contain "{substring}"')
def step_database_url_contains(context: Context, substring: str) -> None:
"""Verify the database URL contains the given substring."""
url = context.settings.database_url
assert substring in url, (
f"Expected database URL to contain '{substring}', got: {url}"
)
@then("the database URL should be an absolute path")
def step_database_url_is_absolute(context: Context) -> None:
"""Verify the database URL uses an absolute path (not relative)."""
url = context.settings.database_url
# For SQLite URLs: sqlite:////absolute/path or sqlite:///relative
# Absolute paths have 4 slashes: sqlite:////home/...
# Relative paths have 3 slashes: sqlite:///relative
assert url.startswith("sqlite:////") or (
url.startswith("sqlite:///") and Path(url[len("sqlite:///") :]).is_absolute()
), f"Expected database URL to use an absolute path, got: {url}"