Skip to content

feat(postgres): add query result assertion steps#144

Open
alileza wants to merge 1 commit intomainfrom
feat/postgres-query-result-assertion
Open

feat(postgres): add query result assertion steps#144
alileza wants to merge 1 commit intomainfrom
feat/postgres-query-result-assertion

Conversation

@alileza
Copy link
Copy Markdown
Member

@alileza alileza commented Mar 10, 2026

Summary

  • Add two new postgres handler steps for executing arbitrary SQL queries and asserting on the result set
  • Enables verifying JSONB fields, aggregations, filtered queries, and joined results in BDD tests

New steps

  • "<resource>" query "<sql>" returns: — asserts exact match of returned rows (count + values)
  • "<resource>" query result of "<sql>" contains: — asserts returned rows are a superset of the expected table

Example

# Exact match
Then "db" query "SELECT count(*) as cnt FROM orders" returns:
  | cnt |
  | 42  |

# Superset check — result may have more rows
Then "db" query result of "SELECT name, email FROM users" contains:
  | name  | email          |
  | Alice | alice@test.com |

Both steps support {{variable}} interpolation.

Test plan

  • go build ./... passes
  • Added 3 integration test scenarios in postgres.feature
  • All postgres integration tests pass locally

Add two new steps for executing arbitrary SQL queries and asserting results:
- query "<sql>" returns: — asserts exact match of returned rows
- query result of "<sql>" contains: — asserts result is a superset of expected rows
@github-actions
Copy link
Copy Markdown

🔴 Integration Test Coverage: 32.0%

📊 Coverage by function (top 30)
github.com/tomatool/tomato/command/docs.go:47:				runDocs				0.0%
github.com/tomatool/tomato/command/docs.go:89:				collectStepCategories		0.0%
github.com/tomatool/tomato/command/docs.go:153:				buildCategoryWithGroups		0.0%
github.com/tomatool/tomato/command/docs.go:372:				generateMkDocs			0.0%
github.com/tomatool/tomato/command/docs.go:464:				generateMarkdown		0.0%
github.com/tomatool/tomato/command/docs.go:513:				generateHTML			0.0%
github.com/tomatool/tomato/command/init.go:114:				initialInitModel		0.0%
github.com/tomatool/tomato/command/init.go:125:				findDockerfiles			0.0%
github.com/tomatool/tomato/command/init.go:165:				Init				0.0%
github.com/tomatool/tomato/command/init.go:169:				Update				0.0%
github.com/tomatool/tomato/command/init.go:221:				handleTextInput			0.0%
github.com/tomatool/tomato/command/init.go:249:				getMaxCursor			0.0%
github.com/tomatool/tomato/command/init.go:264:				handleEnter			0.0%
github.com/tomatool/tomato/command/init.go:315:				View				0.0%
github.com/tomatool/tomato/command/init.go:484:				runInit				0.0%
github.com/tomatool/tomato/command/init.go:539:				generateTomatoConfig		0.0%
github.com/tomatool/tomato/command/init.go:763:				generateExampleFeatureFile	0.0%
github.com/tomatool/tomato/command/root.go:8:				Run				100.0%
github.com/tomatool/tomato/command/run.go:79:				runTests			64.8%
github.com/tomatool/tomato/command/run.go:307:				printKeepAliveInfo		0.0%
github.com/tomatool/tomato/command/run.go:369:				waitForInterrupt		0.0%
github.com/tomatool/tomato/command/steps.go:34:				runSteps			0.0%
github.com/tomatool/tomato/command/ui.go:142:				runWebUI			0.0%
github.com/tomatool/tomato/command/ui.go:226:				watchPath			0.0%
github.com/tomatool/tomato/command/ui.go:247:				watchLoop			0.0%
github.com/tomatool/tomato/command/ui.go:305:				broadcastUpdate			0.0%
github.com/tomatool/tomato/command/ui.go:327:				handleFeatures			0.0%
github.com/tomatool/tomato/command/ui.go:338:				handleConfig			0.0%
github.com/tomatool/tomato/command/ui.go:352:				handleRun			0.0%
github.com/tomatool/tomato/command/ui.go:376:				handleStop			0.0%

Coverage generated from make integration-test-coverage

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