test: add TDD bug-capture test for #1141 — session create persistence #1144
@@ -2,6 +2,12 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Added TDD bug-capture tests for bug #1141 — session create does not persist
|
||||
into subsequent session list output. Added a Behave scenario and Robot E2E
|
||||
test with required tags (`@tdd_bug`, `@tdd_bug_1141`, `@tdd_expected_fail` /
|
||||
`tdd_bug`, `tdd_bug_1141`, `tdd_expected_fail`) to assert create→list should
|
||||
show one session. The underlying assertion currently fails and is intentionally
|
||||
inverted until bug #1141 is fixed. (#1142)
|
||||
- Implemented `--mount` flag on `resource add container-instance`. Supports
|
||||
resource-reference mounts (`--mount local/api-repo:/workspace`) and
|
||||
host-path mounts (`--mount /var/config:/config:ro`). Multiple `--mount`
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
"""Step definitions for TDD Bug #1141 — session create does not persist.
|
||||
|
||||
Steps exercise the create-then-list round-trip through the real DI path.
|
||||
All step names use the ``tdd1141`` prefix to avoid ``AmbiguousStep``
|
||||
collisions with existing session create/list steps.
|
||||
|
||||
The shared ``Given a CLI runner using the real session DI path`` step
|
||||
(from ``tdd_session_shared_steps.py``) handles setup and cleanup:
|
||||
temp database, DI reset, structlog suppression, and cleanup registration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from behave import then, when
|
||||
from behave.runner import Context
|
||||
|
||||
from cleveragents.cli.main import app as main_app
|
||||
|
||||
|
||||
@when("I tdd1141 invoke init with force yes")
|
||||
def step_tdd1141_invoke_init(context: Context) -> None:
|
||||
"""Invoke ``init --force --yes`` via the root CLI app."""
|
||||
context.tdd1141_init_result = context.runner.invoke(
|
||||
main_app, ["init", "--force", "--yes"]
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 init should exit successfully")
|
||||
def step_tdd1141_init_exits_ok(context: Context) -> None:
|
||||
"""Assert init exits with code 0."""
|
||||
result = context.tdd1141_init_result
|
||||
assert result.exit_code == 0, (
|
||||
f"Expected init exit code 0, got {result.exit_code}.\nOutput:\n{result.output}"
|
||||
)
|
||||
|
||||
|
||||
@when("I tdd1141 invoke session create")
|
||||
def step_tdd1141_invoke_create(context: Context) -> None:
|
||||
"""Invoke ``session create`` through the root CLI app."""
|
||||
context.tdd1141_create_result = context.runner.invoke(
|
||||
main_app, ["session", "create"]
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 session create should exit successfully")
|
||||
def step_tdd1141_create_exits_ok(context: Context) -> None:
|
||||
"""Assert session create exits with code 0."""
|
||||
result = context.tdd1141_create_result
|
||||
assert result.exit_code == 0, (
|
||||
f"Expected session create exit code 0, got {result.exit_code}.\n"
|
||||
f"Output:\n{result.output}"
|
||||
)
|
||||
|
||||
|
||||
@when("I tdd1141 invoke session list with format json")
|
||||
def step_tdd1141_invoke_list_json(context: Context) -> None:
|
||||
"""Invoke ``session list --format json`` through the root CLI app."""
|
||||
context.tdd1141_list_result = context.runner.invoke(
|
||||
main_app, ["session", "list", "--format", "json"]
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 session list should exit successfully")
|
||||
def step_tdd1141_list_exits_ok(context: Context) -> None:
|
||||
"""Assert session list exits with code 0."""
|
||||
result = context.tdd1141_list_result
|
||||
assert result.exit_code == 0, (
|
||||
f"Expected session list exit code 0, got {result.exit_code}.\n"
|
||||
f"Output:\n{result.output}"
|
||||
)
|
||||
|
||||
|
||||
@then("the tdd1141 session list output should report total {count:d}")
|
||||
def step_tdd1141_list_contains_count(context: Context, count: int) -> None:
|
||||
"""Assert the JSON output reports the expected total session count."""
|
||||
output = context.tdd1141_list_result.output
|
||||
try:
|
||||
data = json.loads(output)
|
||||
except json.JSONDecodeError as exc:
|
||||
raise AssertionError(
|
||||
f"Session list output is not valid JSON:\n{output}"
|
||||
) from exc
|
||||
|
||||
actual = data.get("total")
|
||||
assert actual == count, (
|
||||
f"Expected 'total': {count} in session list output, got {actual!r}.\n"
|
||||
f"Full output:\n{output}"
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
@tdd_expected_fail @tdd_issue @tdd_issue_1141
|
||||
Feature: TDD Bug #1141 — session create does not persist for session list
|
||||
As a developer
|
||||
I want to verify that a session created via `agents session create`
|
||||
appears in a subsequent `agents session list`
|
||||
So that the persistence bug is captured and will be caught by a regression test
|
||||
|
||||
The bug: `agents session create` succeeds (exit code 0) but the created
|
||||
session does not appear when `agents session list` is invoked immediately
|
||||
after. This test captures bug #1141 and intentionally keeps
|
||||
`@tdd_expected_fail` so CI passes while the bug remains unfixed.
|
||||
|
||||
Scenario: Init then create should make list total increase from 0 to 1
|
||||
Given a CLI runner using the real session DI path
|
||||
When I tdd1141 invoke init with force yes
|
||||
Then the tdd1141 init should exit successfully
|
||||
When I tdd1141 invoke session list with format json
|
||||
Then the tdd1141 session list should exit successfully
|
||||
And the tdd1141 session list output should report total 0
|
||||
When I tdd1141 invoke session create
|
||||
Then the tdd1141 session create should exit successfully
|
||||
When I tdd1141 invoke session list with format json
|
||||
Then the tdd1141 session list should exit successfully
|
||||
And the tdd1141 session list output should report total 1
|
||||
@@ -0,0 +1,20 @@
|
||||
*** Settings ***
|
||||
Documentation TDD Bug #1141 — session create does not persist session
|
||||
... for subsequent list. This test captures the bug described
|
||||
... in #1141. The tdd_expected_fail tag inverts the result so
|
||||
... CI passes while the bug is unfixed. Remove the tag when
|
||||
... the fix is merged.
|
||||
Resource common_e2e.resource
|
||||
Suite Setup E2E Suite Setup
|
||||
Suite Teardown E2E Suite Teardown
|
||||
|
||||
*** Test Cases ***
|
||||
Session Create Then List Shows Session
|
||||
[Documentation] Create a session and verify it appears in session list.
|
||||
[Tags] E2E tdd_expected_fail tdd_issue tdd_issue_1141
|
||||
Run CleverAgents Command init --force --yes
|
||||
${r1}= Run CleverAgents Command session list --format json
|
||||
Should Contain ${r1.stdout} "total": 0
|
||||
Run CleverAgents Command session create --format plain
|
||||
${r2}= Run CleverAgents Command session list --format json
|
||||
Should Contain ${r2.stdout} "total": 1
|
||||
Reference in New Issue
Block a user