Files
cleveragents-core/features/sql_string_aware_coverage.feature
freemo 051ee7c290
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 21s
CI / quality (pull_request) Successful in 31s
CI / typecheck (pull_request) Successful in 47s
CI / security (pull_request) Successful in 52s
CI / build (pull_request) Successful in 56s
CI / e2e_tests (pull_request) Successful in 5m1s
CI / integration_tests (pull_request) Successful in 5m30s
CI / unit_tests (pull_request) Successful in 5m42s
CI / docker (pull_request) Successful in 58s
CI / coverage (pull_request) Successful in 7m35s
CI / build (push) Successful in 21s
CI / docker (push) Has been skipped
CI / benchmark-regression (pull_request) Failing after 49m24s
CI / lint (push) Successful in 22s
CI / quality (push) Successful in 39s
CI / security (push) Successful in 48s
CI / typecheck (push) Successful in 1m26s
CI / benchmark-regression (push) Has been skipped
CI / e2e_tests (push) Successful in 5m53s
CI / coverage (push) Successful in 9m4s
CI / benchmark-publish (push) Successful in 19m10s
CI / integration_tests (push) Failing after 19m18s
CI / unit_tests (push) Failing after 19m20s
test(coverage): add Behave BDD tests to improve coverage across 52 source files
Added 52 new .feature files and corresponding _steps.py files targeting
previously uncovered code paths in the following areas:

- TUI layer: app, commands, persona (state/schema/registry), widgets,
  input (shell_exec, reference_parser)
- Application services: plan lifecycle/service/executor, session,
  project, repo indexing, correction, checkpoint, actor, llm_actors,
  strategy coordinator, resource file watcher, service retry wiring
- CLI commands: session, resource, repl, plan, db, automation_profile
- Domain models: retry_policy, resource_type, cost_budget,
  docker_compose_analyzer, detail_level, _sql_string_aware,
  _postgresql_helpers
- Core: circuit_breaker, retry_service_patterns
- Infrastructure: repositories, transaction_sandbox, strategy_registry,
  plugins/loader, container
- Config: settings
- Agents: plan_generation, context_analysis, auto_debug
- A2A: facade

All new tests follow the Behave/Gherkin BDD standard. Resolved step
definition collisions with unique prefixes. Fixed Alembic fileConfig
logger disabling issue (disable_existing_loggers=False).

ISSUES CLOSED: #1068
2026-03-20 21:22:10 +00:00

102 lines
5.4 KiB
Gherkin

Feature: SQL String-Aware scanning utilities coverage
Exercise uncovered code paths in _sql_string_aware.py including
dollar-quoted strings, escaped single quotes, and nested block
comments for both strip_sql_comments and find_unquoted_semicolon.
Background:
Given the sql_string_aware module is imported
# -----------------------------------------------------------------------
# strip_sql_comments — escaped single quotes (line 40)
# -----------------------------------------------------------------------
Scenario: strip_sql_comments preserves escaped single quotes inside strings
Given SQL content "SELECT 'it''s a test'"
When I strip SQL comments
Then the stripped result should be "SELECT 'it''s a test'"
Scenario: strip_sql_comments preserves multiple escaped quotes in one literal
Given SQL content "SELECT 'he said ''hello'' to her'"
When I strip SQL comments
Then the stripped result should be "SELECT 'he said ''hello'' to her'"
# -----------------------------------------------------------------------
# strip_sql_comments — dollar-quoted strings, terminated (lines 52-58)
# -----------------------------------------------------------------------
Scenario: strip_sql_comments preserves a terminated dollar-quoted string with anonymous tag
Given SQL content with a terminated anonymous dollar-quoted string
When I strip SQL comments
Then the dollar-quoted body should be preserved intact
Scenario: strip_sql_comments preserves a terminated dollar-quoted string with named tag
Given SQL content with a terminated named dollar-quoted string
When I strip SQL comments
Then the named dollar-quoted body should be preserved intact
# -----------------------------------------------------------------------
# strip_sql_comments — dollar-quoted strings, unterminated (lines 60-62)
# -----------------------------------------------------------------------
Scenario: strip_sql_comments handles an unterminated dollar-quoted string
Given SQL content with an unterminated dollar-quoted string
When I strip SQL comments
Then the rest of the content should be preserved as-is
# -----------------------------------------------------------------------
# strip_sql_comments — nested block comments (lines 70-71)
# -----------------------------------------------------------------------
Scenario: strip_sql_comments removes nested block comments
Given SQL content "SELECT 1 /* outer /* inner */ still comment */ + 2"
When I strip SQL comments
Then the stripped result should be "SELECT 1 + 2"
Scenario: strip_sql_comments removes deeply nested block comments
Given SQL content "A /* a /* b /* c */ b */ a */ B"
When I strip SQL comments
Then the stripped result should be "A B"
# -----------------------------------------------------------------------
# find_unquoted_semicolon — escaped single quotes (line 115)
# -----------------------------------------------------------------------
Scenario: find_unquoted_semicolon skips semicolons inside escaped single-quoted strings
Given SQL content "SELECT 'it''s;here'; DROP TABLE"
When I search for the first unquoted semicolon
Then the semicolon index should point to the one after the closing quote
Scenario: find_unquoted_semicolon with multiple escaped quotes before semicolon
Given SQL content "'a''b''c';X"
When I search for the first unquoted semicolon
Then the semicolon index should be 9
# -----------------------------------------------------------------------
# find_unquoted_semicolon — dollar-quoted strings, terminated (lines 125-129)
# -----------------------------------------------------------------------
Scenario: find_unquoted_semicolon skips semicolons inside dollar-quoted strings
Given SQL content with dollar-quoted string containing a semicolon then real semicolon
When I search for the first unquoted semicolon
Then the semicolon should be found after the dollar-quoted string
Scenario: find_unquoted_semicolon skips named dollar-quoted strings
Given SQL content with named dollar-quoted string containing a semicolon then real semicolon
When I search for the first unquoted semicolon
Then the semicolon should be found after the named dollar-quoted string
# -----------------------------------------------------------------------
# find_unquoted_semicolon — dollar-quoted strings, unterminated (line 129 else)
# -----------------------------------------------------------------------
Scenario: find_unquoted_semicolon returns -1 for unterminated dollar-quoted string
Given SQL content with an unterminated dollar-quoted string containing a semicolon
When I search for the first unquoted semicolon
Then ssacov the result should be -1 indicating no unquoted semicolon
# -----------------------------------------------------------------------
# Combined / integration-style
# -----------------------------------------------------------------------
Scenario: strip_sql_comments handles mix of dollar-quoted strings and comments
Given SQL content mixing dollar-quoted strings and comments
When I strip SQL comments
Then only the comments should be removed and dollar strings preserved
Scenario: find_unquoted_semicolon with start offset skipping initial semicolons
Given SQL content ";$$body;$$;end"
When I search for unquoted semicolon starting at offset 1
Then the semicolon should be found at index 10