psqlxtest

package module
v0.0.0-...-b94ca08 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: MIT Imports: 9 Imported by: 0

README

psqlxtest

Create an isolated postgres database instance per test case.

Example test

func TestSomething(t *testing.T) {
	dbx, drop := psqlxtest.TmpDB(t)
	defer drop()

	// Run in an isolated postgres database instance.
	dbx.Exec(/* ... */)
}

Example usage

# Run postgres
docker run --name my-test-postgres -p 5432:5432 -d postgres

# Run your tests
go test ./mypkg

Documentation

Overview

Package psqlxtest provides utilities for creating isolated postgres database instances with sqlx connections for testing purposes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TmpDB

func TmpDB(t *testing.T) (*sqlx.DB, func())

TmpDB creates a temporary database and returns a function to remove it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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