Skip to content

feat(postgres): add variable interpolation to postgres steps#141

Closed
alileza wants to merge 1 commit intotomatool:mainfrom
alileza:feat/postgres-variable-interpolation
Closed

feat(postgres): add variable interpolation to postgres steps#141
alileza wants to merge 1 commit intotomatool:mainfrom
alileza:feat/postgres-variable-interpolation

Conversation

@alileza
Copy link
Copy Markdown
Member

@alileza alileza commented Mar 3, 2026

Summary

  • Add {{variable}} interpolation support to postgres handler steps, matching the behavior already present in the HTTP client handler
  • Previously, variables captured via HTTP response steps (e.g. saved as "{{cr_id}}") could not be used in postgres steps — this made it impossible to cross-reference HTTP-created resources with direct database assertions

What changed

Three postgres handler methods now call ReplaceVariables() on their inputs:

  • executeSQL — interpolates docstring content before executing
  • setTableValues — interpolates cell values when inserting rows
  • tableShouldContain — interpolates expected cell values when asserting

Example

This now works:

# Save an ID from HTTP response
When "api" sends "POST" to "/api/users"
Then "api" response json "id" saved as "{{user_id}}"

# Use it in a postgres assertion
Then "db" table "users" contains:
  | id           | status |
  | {{user_id}}  | active |

# Or in raw SQL
Given "db" executes:
  """
  UPDATE users SET verified = true WHERE id = '{{user_id}}'
  """

Test plan

  • Verified go build ./... passes
  • Manually tested with a project that uses HTTP + postgres steps together

Add {{variable}} interpolation support to postgres handler steps,
matching the behavior already present in the HTTP client handler.

Previously, variables captured via HTTP response steps (e.g. saved as
"{{cr_id}}") could not be used in postgres steps like "executes",
"table contains", or "table has values". This made it impossible to
cross-reference HTTP-created resources with direct database assertions.

Affected steps:
- "executes:" (raw SQL) — interpolates docstring content
- "table has values:" (insert) — interpolates cell values
- "table contains:" (assert) — interpolates expected cell values
@alileza
Copy link
Copy Markdown
Member Author

alileza commented Mar 10, 2026

Closing fork PR — reopening directly from org repo to fix CI permissions issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant