postgres

package
v0.0.0-...-8cec58f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteSQL

func ExecuteSQL(ctx context.Context, ds sqlutil.DataSource, migrationSQL string) error

ExecuteSQL executes the given SQL migration on the provided sqlx.DB or DataSource. This is a convenience helper for running CREATE TABLE and other DDL statements.

Usage:

db := pgtest.SetupTestDB(t)
ds := sqlutil.WrapDataSource(db, logger.Test(t))
err := pgtest.ExecuteSQL(ctx, ds, testdata.CreateLogPollerTables)
require.NoError(t, err)

func SetupTestDB

func SetupTestDB(t testing.TB) sqlutil.DataSource

SetupTestDB creates a test database with DataSource wrapper using chainlink-testing-framework's postgres testcontainer.

This function: 1. Starts a PostgreSQL Docker container automatically 2. Creates a fresh database for the test 3. Returns a sqlutil.DataSource (wrapped sqlx.DB) 4. Auto-cleans up container and database after test completion

This does NOT: - Run chainlink migrations - Start chainlink node - Configure blockchains

You must manually create your tables after calling this function.

Usage:

ds := pgtest.SetupTestDB(t)
err := pgtest.ApplyMigration(ctx, ds, testdata.CreateLogPollerTables)
require.NoError(t, err)

Requirements:

  • Docker must be running on the machine
  • No environment variables needed

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL