Files
cleveragents-core/features/postgresql_helpers_coverage.feature

96 lines
4.7 KiB
Gherkin

Feature: PostgreSQL Helpers Coverage
Additional scenarios that exercise previously uncovered code paths
in the _postgresql_helpers module (lines 50, 192, 197-204, 215, 230, 384-388, 434).
Background:
Given the postgresql helpers module is imported
# --- ident_pair: quoted identifier with escaped double-quotes (line 50) ---
Scenario: ident_pair returns unescaped quoted identifier
Given a regex match with a quoted identifier containing escaped double-quotes
When I call ident_pair on the quoted match
Then the result should have double-quotes unescaped
# --- _skip_quoted: escaped quote inside string (line 192) ---
Scenario: extract_body handles escaped single-quotes inside strings
Given SQL content with parenthesized body containing escaped single-quotes
When I call extract_body on the content
Then the body should be extracted correctly with the quoted string intact
Scenario: split_entries handles escaped double-quotes inside identifiers
Given a table body with escaped double-quotes in an identifier
When I call split_entries on the body
Then the entries should be split correctly preserving the identifier
# --- _skip_quoted: unclosed quote returns end of string (line 197) ---
Scenario: extract_body handles unclosed single-quote gracefully
Given SQL content with an unclosed single-quote inside parentheses
When I call extract_body on the unclosed-quote content
Then extract_body should return an empty string for unbalanced parens
# --- _skip_quoted: dollar-quoting (lines 198-203) ---
Scenario: extract_body handles dollar-quoted strings
Given SQL content with a dollar-quoted string inside parentheses
When I call extract_body on the dollar-quoted content
Then the body should be extracted correctly ignoring dollar-quoted content
Scenario: split_entries handles dollar-quoted strings with commas inside
Given a table body containing a dollar-quoted string with commas
When I call split_entries on the dollar-quoted body
Then the comma inside the dollar-quoted string should not split entries
Scenario: extract_body handles unclosed dollar-quoted string
Given SQL content with an unclosed dollar-quoted string
When I call extract_body on the unclosed dollar-quote content
Then extract_body should handle the unclosed dollar-quote gracefully
# --- _skip_quoted: lone dollar sign not forming dollar-quote (line 204) ---
Scenario: extract_body handles lone dollar sign not forming dollar-quote
Given SQL content with a lone dollar sign that is not a dollar-quote tag
When I call extract_body on the lone-dollar content
Then the body should be extracted correctly ignoring the lone dollar
# --- extract_body: invalid paren_start (line 215) ---
Scenario: extract_body returns empty string for out-of-bounds paren_start
When I call extract_body with paren_start beyond content length
Then extract_body should return an empty string for invalid start
Scenario: extract_body returns empty string when paren_start is not a paren
When I call extract_body with paren_start pointing at a non-paren character
Then extract_body should return an empty string for non-paren start
# --- extract_body: unbalanced parentheses (line 230) ---
Scenario: extract_body returns empty string for unbalanced opening paren
Given SQL content with an opening paren but no closing paren
When I call extract_body on the unbalanced content
Then extract_body should return an empty string for missing close paren
# --- extract_fk_triples: column count mismatch (lines 384-388) ---
Scenario: extract_fk_triples warns on source/target column count mismatch
Given a FOREIGN KEY clause with mismatched source and target column counts
When I extract FK triples from the mismatched clause
Then a warning should be logged about the column count mismatch
And triples should be generated only for the shorter column list
# --- parse_table_body: empty entry triggers continue (line 434) ---
Scenario: parse_table_body skips empty entries in the table body
Given a table body string with empty entries between commas
When I call parse_table_body on the body with empty entries
Then parse_table_body should produce triples only for valid column definitions
# --- Combined: FK with quoted schema containing escaped double-quotes (line 50 via extract_fk_triples) ---
Scenario: extract_fk_triples handles quoted schema with escaped double-quotes
Given a FOREIGN KEY clause referencing a quoted schema with escaped double-quotes
When I extract FK triples from the quoted-schema clause
Then the triples should reference the correctly unescaped schema name