Documentation ¶
Index ¶
- func Connect(ctx context.Context, t *testing.T, connectionString string) *sql.DB
- func Migrate(url string, dir fs.FS) error
- type PostgresContainer
- type Query
- type Recorder
- func (d *Recorder) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (d *Recorder) Query(ctx context.Context, query string, args ...interface{}) (*database.Rows, error)
- func (d *Recorder) QueryRow(ctx context.Context, query string, args ...interface{}) *database.Row
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PostgresContainer ¶
type PostgresContainer struct { *postgres.PostgresContainer ConnectionString string }
func SetupPostgres ¶
func SetupPostgres(t *testing.T, dbName string, setup func(connectionString string) error) *PostgresContainer
SetupPostgres sets up a test database and runs the provided setup function. It also sets up a cleanup function to terminate the container after the test is complete.
type Recorder ¶
type Recorder struct { Queries []Query RowQueries []Query ExecQueries []Query // contains filtered or unexported fields }
Recorder records all queries and arguments that are passed to the database.
func NewRecorder ¶
NewRecorder creates a new query Recorder.
Click to show internal directories.
Click to hide internal directories.