fix(test): separate DATABASE_URL and TEST_DATABASE_URL in test step configuration #732

Open
opened 2026-03-12 13:19:05 +00:00 by CoreRasurae · 0 comments
Member

Metadata

  • Commit Message: fix(test): separate DATABASE_URL and TEST_DATABASE_URL in test step configuration
  • Branch: fix/m3-duplicate-db-urls

Summary

In features/steps/cli_plan_context_commands_steps.py, both CLEVERAGENTS_DATABASE_URL and CLEVERAGENTS_TEST_DATABASE_URL are set to the same SQLite file path. This could mask bugs where the production vs. test URL selection logic matters, since both URLs resolve to the same database.

Background and Context

Identified during the code review of PR #727 (Finding #9 in the APPROVED review by @hurui200320). This is a pre-existing issue not introduced by that PR.

Current Behavior

# features/steps/cli_plan_context_commands_steps.py:96-100
os.environ["CLEVERAGENTS_DATABASE_URL"] = f"sqlite:///{db_file}"
os.environ["CLEVERAGENTS_TEST_DATABASE_URL"] = f"sqlite:///{db_file}"

Both environment variables point to the same file. Any code that selects between the two URLs based on context (production vs. test mode) will always get the same result, making it impossible to detect selection bugs in tests.

Expected Behavior

The two environment variables should point to different database files so that tests can verify the application correctly selects the appropriate URL based on context. For example:

os.environ["CLEVERAGENTS_DATABASE_URL"] = f"sqlite:///{db_file}"
os.environ["CLEVERAGENTS_TEST_DATABASE_URL"] = f"sqlite:///{test_db_file}"

Acceptance Criteria

  • CLEVERAGENTS_DATABASE_URL and CLEVERAGENTS_TEST_DATABASE_URL point to different files in test steps
  • Tests that exercise URL selection logic can distinguish between the two
  • All existing scenarios still pass
  • No new test failures or resource leaks

Supporting Information

Subtasks

  • Audit how CLEVERAGENTS_DATABASE_URL vs. CLEVERAGENTS_TEST_DATABASE_URL are consumed in production code
  • Create a separate temp DB file for CLEVERAGENTS_TEST_DATABASE_URL in the step setup
  • Update cli_plan_context_commands_steps.py:96-100 to use distinct files
  • Verify cleanup handles both files in after_scenario
  • Run nox -s unit_tests to verify no regressions

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `fix(test): separate DATABASE_URL and TEST_DATABASE_URL in test step configuration` - **Branch**: `fix/m3-duplicate-db-urls` ## Summary In `features/steps/cli_plan_context_commands_steps.py`, both `CLEVERAGENTS_DATABASE_URL` and `CLEVERAGENTS_TEST_DATABASE_URL` are set to the same SQLite file path. This could mask bugs where the production vs. test URL selection logic matters, since both URLs resolve to the same database. ## Background and Context Identified during the code review of PR #727 (Finding #9 in the APPROVED review by @hurui200320). This is a pre-existing issue not introduced by that PR. ## Current Behavior ```python # features/steps/cli_plan_context_commands_steps.py:96-100 os.environ["CLEVERAGENTS_DATABASE_URL"] = f"sqlite:///{db_file}" os.environ["CLEVERAGENTS_TEST_DATABASE_URL"] = f"sqlite:///{db_file}" ``` Both environment variables point to the same file. Any code that selects between the two URLs based on context (production vs. test mode) will always get the same result, making it impossible to detect selection bugs in tests. ## Expected Behavior The two environment variables should point to different database files so that tests can verify the application correctly selects the appropriate URL based on context. For example: ```python os.environ["CLEVERAGENTS_DATABASE_URL"] = f"sqlite:///{db_file}" os.environ["CLEVERAGENTS_TEST_DATABASE_URL"] = f"sqlite:///{test_db_file}" ``` ## Acceptance Criteria - [ ] `CLEVERAGENTS_DATABASE_URL` and `CLEVERAGENTS_TEST_DATABASE_URL` point to different files in test steps - [ ] Tests that exercise URL selection logic can distinguish between the two - [ ] All existing scenarios still pass - [ ] No new test failures or resource leaks ## Supporting Information - Identified in: PR #727 Code Review, Finding #9 (APPROVED review) - Review URL: https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/727 - Reviewer: @hurui200320 ## Subtasks - [ ] Audit how `CLEVERAGENTS_DATABASE_URL` vs. `CLEVERAGENTS_TEST_DATABASE_URL` are consumed in production code - [ ] Create a separate temp DB file for `CLEVERAGENTS_TEST_DATABASE_URL` in the step setup - [ ] Update `cli_plan_context_commands_steps.py:96-100` to use distinct files - [ ] Verify cleanup handles both files in `after_scenario` - [ ] Run `nox -s unit_tests` to verify no regressions ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added this to the v3.2.0 milestone 2026-03-12 21:01:15 +00:00
freemo self-assigned this 2026-04-02 06:13:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#732
No description provided.