glsql

package
v1.87.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package glsql (Gitaly SQL) is a helper package to work with plain SQL queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean() error

Clean removes created schema if any and releases DB connection pool. It needs to be called only once after all tests for package are done. The best place to use it is TestMain(*testing.M) {...} after m.Run().

func Migrate

func Migrate(db *sql.DB) (int, error)

Migrate will apply all pending SQL migrations.

func OpenDB

func OpenDB(conf config.DB) (*sql.DB, error)

OpenDB returns connection pool to the database.

Types

type DB

type DB struct {
	*sql.DB
}

DB is a helper struct that should be used only for testing purposes.

func GetDB

func GetDB(t testing.TB) DB

GetDB returns a wrapper around the database connection pool. Must be used only for testing. The new database 'gitaly_test' will be re-created for each package that uses this function. The best place to call it is in individual testing functions It uses env vars:

PGHOST - required, URL/socket/dir
PGPORT - required, binding port
PGUSER - optional, user - `$ whoami` would be used if not provided

func (DB) Close

func (db DB) Close() error

Close removes schema if it was used and releases connection pool.

func (DB) Truncate

func (db DB) Truncate(t testing.TB, tables ...string)

Truncate removes all data from the list of tables and restarts identities for them.

Jump to

Keyboard shortcuts

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