This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
QuickQuery is a lightweight Go library for testing PostgreSQL database interactions. It wraps pgx/v4 and testify to provide convenient helper methods for executing SQL queries and asserting results during tests.
go build ./... # Build the package
go test ./... # Run tests
go mod tidy # Clean up dependenciesThe library has two main types:
Database pool wrapper that validates test database naming (requires _test suffix) and manages pgxpool.Pool connections. Factory for creating QuickQuery instances.
Test helper that provides:
- Automatic transaction creation with rollback on
Done()for test isolation - Context with 10-second default timeout
- Integrated testify assertions (
Afor assert,Rfor require) - Type-safe query methods:
Bool(),Int(),Int64(),String(),Time(),UUID(),IsNull() Exec()for non-query statementsThrows(sql, pgErrCode)for PostgreSQL SQLSTATE error validation
db := quickquery.NewTestDB(t, connString) // Validates _test suffix
defer db.TearDown()
qq := db.QQ(t)
defer qq.Done() // Rollback + context cancel
result := qq.String("SELECT name FROM users WHERE id = $1", 1)github.com/jackc/pgx/v4- PostgreSQL drivergithub.com/stretchr/testify- Assertions