Skip to main content
Testereiro - Test Engine Toolkit for Go
GitHub Go Docs Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Bancoche (SQL Runner)

Package: github.com/wrapped-owls/testereiro/puppetest/pkg/atores/bancoche

bancoche runs SQL queries and validates rows.

Basic Usage

1
2
3
4
5
6
7
runner := bancoche.New(
	engine.DB(),
	bancoche.WithMapQuery("jokers", map[string]any{"rarity": "Common"}),
	bancoche.ExpectCount(2, true),
)

err := engine.Execute(t, runner)

Query Builders

  • WithMapQuery(table, filter)
  • WithMapQueryFromCtx(table, fn)
  • WithQuery(bancoche.NewRawQuery(query, args...))

Validators

  • ExpectCount(expected, countRows)
  • WithCustomValidation(func(t testing.TB, rows *sql.Rows) error)

WithCustomValidation is useful when row scanning logic is domain-specific.

ExpectCount behavior:

  • countRows=true: counts the number of returned rows.
  • countRows=false: expects the query to return a COUNT(*)-style single value and scans it.