pgtest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pgtest provides simple utility functions for creating temporary databases in PostgreSQL. It was designed to be used in integration tests in the following way:

func TestSomethingThatUsesPostgres(t *testing.T) {

    // create pool and schedule cleanup function
    pool, cleanup := pgtest.PrepareWithSchema(t, "../storage/schema/schema.sql")
    defer cleanup()
    // use pool in your code
    accountID := prepareTestAccount(t, pool)
    ...
}

It's not production ready and was specifically tailored for spendshelf-backend requirements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareWithSchema

func PrepareWithSchema(t *testing.T, schemaFilePath string) (*pgxpool.Pool, func())

PrepareWithSchema returns pgxpool.Pool instance and cleanup function, that can be used in integration tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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