pgtest

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pgtest gives the tests a PostgreSQL database of their own, on the server of XTRADER_TEST_DATABASE_URL, eg: a container of postgres:18.6: the tests are skipped without it.

Index

Constants

View Source
const Env = "XTRADER_TEST_DATABASE_URL"

Env is the variable of the URL of the server of the tests, of a user allowed to create databases.

Variables

This section is empty.

Functions

func DSN

func DSN(t *testing.T, name string) string

DSN returns the URL of the database name on the server of the tests.

func Database

func Database(t *testing.T) string

Database creates an empty database for the test, dropped at its end, and returns its URL.

func Migrate

func Migrate(t *testing.T, dsn, root string)

Migrate applies the migrations and the seeds of the repository at root to the database of dsn. The agents the seeds add (sql/seeds/0004_agents.sql) are taken out again, the tests starting without any: the ones there before are kept. MigrateSeeded keeps them.

func MigrateSeeded

func MigrateSeeded(t *testing.T, dsn, root string)

MigrateSeeded is Migrate keeping the agents of the seeds.

func Migrated

func Migrated(t *testing.T, root string) string

Migrated creates a database for the test with the migrations and the seeds of the sql directory of the repository, root its path from the test, eg: "..", as cmd/migrator does, and returns its URL.

Types

This section is empty.

Jump to

Keyboard shortcuts

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