Files
cleveragents-core/robot/tdd_sqlite_url_cwd.robot
T
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

40 lines
2.0 KiB
Plaintext

*** Settings ***
Documentation TDD Issue #1024 — SQLite DB URL resolves to CWD instead of CLEVERAGENTS_HOME
... Integration tests verifying that the database URL resolves
... inside CLEVERAGENTS_HOME rather than the current working
... directory. The default ``database_url`` in Settings is
... ``sqlite:///cleveragents.db`` — a relative path that resolves
... against CWD, breaking test isolation when CLEVERAGENTS_HOME
... points to a different directory.
...
... Bug: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1024
... TDD: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1034
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
*** Variables ***
${HELPER} ${CURDIR}/helper_tdd_sqlite_url_cwd.py
*** Test Cases ***
TDD SQLite DB URL Resolves Inside CLEVERAGENTS_HOME
[Documentation] Verify that ``get_database_url()`` resolves the database
... path inside CLEVERAGENTS_HOME when no explicit database URL
... is provided via environment variable.
${result}= Run Process ${PYTHON} ${HELPER} check-db-url-resolution cwd=${WORKSPACE} timeout=60s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tdd-sqlite-url-cwd-resolution-ok
TDD CLI Command Creates DB Inside CLEVERAGENTS_HOME
[Documentation] Verify that a CLI command (session list) creates the
... database file inside CLEVERAGENTS_HOME, not in CWD.
${result}= Run Process ${PYTHON} ${HELPER} check-cli-db-location cwd=${WORKSPACE} timeout=60s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tdd-sqlite-url-cwd-cli-ok