Files
temp/features/project_context_set_exec_env_priority.feature
T
brent.edwards 26632f79e9 test: add TDD bug-capture test for #1079 — project context set missing flag (#1130)
## Summary

This PR adds TDD bug-capture tests for bug #1079 (`project context set` missing `--execution-env-priority` flag). Per the Bug Fix Workflow in CONTRIBUTING.md, the first step in fixing any bug is to write a test that proves the bug exists.

### What was done

- **Behave unit tests** (6 scenarios in `features/project_context_set_exec_env_priority.feature`):
  - `project context set --execution-env-priority override` with `--execution-environment` should succeed and persist
  - `project context set --execution-env-priority fallback` with `--execution-environment` should succeed and persist
  - `--execution-env-priority` without `--execution-environment` should be rejected
  - Default to `fallback` when only `--execution-environment` is specified
  - Invalid `--execution-env-priority` value should be rejected
  - `project context show` should reflect persisted `execution_env_priority` in JSON output

- **Robot integration tests** (3 test cases in `robot/project_context_set_exec_env_priority.robot`):
  - Override acceptance with persistence verification
  - Fallback acceptance with persistence verification
  - Full round-trip persistence check

All tests are tagged `@tdd_bug @tdd_bug_1079 @tdd_expected_fail`. The underlying assertions fail (confirming the bug exists — `--execution-env-priority` is "No such option"), and the `@tdd_expected_fail` tag inverts the result so CI passes.

### Bug confirmed

The `context_set()` function in `cleveragents.cli.commands.project_context` does not accept `execution_env_priority` as a parameter. The specification (§Execution Environment Routing, precedence table) requires this flag at precedence level 2 for project-level execution environment priority control.

### Quality gates

| Gate | Result |
|------|--------|
| `nox -s lint` | PASS |
| `nox -s typecheck` | PASS (0 errors) |
| `nox -s unit_tests` | PASS (12236 scenarios, 0 failed) |
| `nox -s integration_tests` | My 3 tests pass (13 pre-existing failures) |
| `nox -s coverage_report` | PASS (98%, threshold 97%) |

Closes #1100

Reviewed-on: cleveragents/cleveragents-core#1130
Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com>
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-28 02:14:55 +00:00

51 lines
3.2 KiB
Gherkin

Feature: Project context set --execution-env-priority flag (Bug #1079)
As a developer
I want to set execution environment priority when using project context set
So that I can control project-level execution environment precedence per spec §Execution Environment Routing
# This feature captures bug #1079: the --execution-env-priority flag is missing
# from the project context set command. The spec requires it at precedence level 2.
# These tests use @tdd_expected_fail because the flag is not yet implemented;
# the tag will be removed when the bug fix in #1079 is merged.
Background:
Given a bug 1079 in-memory database is initialized
And a project "local/bug1079-app" exists for bug 1079
@tdd_issue @tdd_issue_1079 @tdd_expected_fail
Scenario: Bug #1079 - project context set accepts --execution-env-priority override
When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "override"
Then the bug 1079 command should succeed
And the stored bug 1079 execution_env_priority should be "override"
@tdd_issue @tdd_issue_1079 @tdd_expected_fail
Scenario: Bug #1079 - project context set accepts --execution-env-priority fallback
When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "fallback"
Then the bug 1079 command should succeed
And the stored bug 1079 execution_env_priority should be "fallback"
@tdd_issue @tdd_issue_1079 @tdd_expected_fail
Scenario: Bug #1079 - project context set rejects --execution-env-priority without --execution-environment
When I run bug 1079 context set on "local/bug1079-app" with execution_env_priority "override" but no execution_environment
Then the bug 1079 command should fail
And the bug 1079 output should contain "--execution-env-priority requires --execution-environment"
@tdd_issue @tdd_issue_1079 @tdd_expected_fail
Scenario: Bug #1079 - project context set defaults execution-env-priority to fallback when not specified
When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" but no execution_env_priority
Then the bug 1079 command should succeed
And the stored bug 1079 execution_env_priority should be "fallback"
@tdd_issue @tdd_issue_1079 @tdd_expected_fail
Scenario: Bug #1079 - project context set rejects invalid --execution-env-priority value
When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "invalid-value"
Then the bug 1079 command should fail
And the bug 1079 output should contain "Invalid execution env priority"
@tdd_issue @tdd_issue_1079 @tdd_expected_fail
Scenario: Bug #1079 - project context show reflects persisted execution-env-priority
When I run bug 1079 context set on "local/bug1079-app" with execution_environment "host" and execution_env_priority "override"
Then the bug 1079 command should succeed
When I run bug 1079 context show on "local/bug1079-app" with format "json"
Then the bug 1079 command should succeed
And the bug 1079 json output should include "execution_env_priority" as "override"