Files
cleveragents-core/features/tdd_sqlite_url_cwd.feature
freemo 2b6ac00263 fix(config): resolve database_url relative to CLEVERAGENTS_HOME, not CWD
Ensure that when database_url is a relative path (like sqlite:///cleveragents.db),
it resolves relative to CLEVERAGENTS_HOME instead of the current working directory.
This fixes E2E test isolation where data from previous runs persisted across runs
at CWD, causing UNIQUE constraint failures.

Changes:
- Added _resolve_database_urls model validator in Settings to rewrite relative
  SQLite paths to absolute paths under CLEVERAGENTS_HOME
- Updated get_database_url() in container.py to use CLEVERAGENTS_HOME as base
  directory and create parent directories when CLEVERAGENTS_HOME is explicitly set
- Updated _check_database() in system.py to walk up directory tree for writable
  ancestor check, handling cases where intermediate directories have not yet been
  created
- Removed @tdd_expected_fail from TDD test (now passes genuinely)

ISSUES CLOSED: #1024
2026-04-22 00:45:09 +00:00

28 lines
1.4 KiB
Gherkin

@tdd_issue @tdd_issue_1024
Feature: TDD Issue #1024 — SQLite DB URL resolves to CWD instead of CLEVERAGENTS_HOME
As a developer
I want to verify that the SQLite database file is created inside
CLEVERAGENTS_HOME (not the current working directory)
So that test isolation is maintained across CLI invocations
The default ``database_url`` in ``Settings`` is ``sqlite:///cleveragents.db``
a relative path. When E2E tests (or any CLI invocation) run with
``CLEVERAGENTS_HOME`` set to a different directory, the DB file is still
created relative to CWD, NOT inside ``CLEVERAGENTS_HOME``. This breaks
test isolation: data persists across runs, causing UNIQUE constraint
failures.
Bug: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1024
TDD: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1034
Scenario: Default database_url resolves inside CLEVERAGENTS_HOME not CWD
Given a fresh CLEVERAGENTS_HOME temp directory for DB URL testing
When I resolve the effective database URL from Settings
Then the resolved database path should be inside CLEVERAGENTS_HOME
And the resolved database path should not be inside the original CWD
Scenario: Settings database_url default resolves inside CLEVERAGENTS_HOME
Given a fresh CLEVERAGENTS_HOME temp directory for DB URL testing
When I resolve the Settings database_url default
Then the settings database path should be inside CLEVERAGENTS_HOME