postgres

package
v0.0.0-...-2feb83d Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package postgres provides a simple wrapper around 3rd party postgres client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectAndGetDB

func ConnectAndGetDB(t *testing.T, serverAddr string, extras map[string]interface{})

ConnectAndGetDB initiates a connection to the database, get a handle on the test db, and register cleanup handlers for the test. Finally, it saves the db handle and task context in the provided extras map.

func GetPGHandle

func GetPGHandle(t *testing.T, serverAddr string) *sql.DB

GetPGHandle returns a handle on the test Postgres DB. This does not initiate a connection

func RunAlterQuery

func RunAlterQuery(t *testing.T, extras map[string]interface{})

RunAlterQuery runs ALTER query on the test DB.

func RunCreateQuery

func RunCreateQuery(t *testing.T, extras map[string]interface{})

RunCreateQuery creates a new table.

func RunDeleteQuery

func RunDeleteQuery(t *testing.T, extras map[string]interface{})

RunDeleteQuery run a deletion query on the test DB.

func RunDropQuery

func RunDropQuery(t *testing.T, extras map[string]interface{})

RunDropQuery drops a table.

func RunInsertQuery

func RunInsertQuery(t *testing.T, id int64, extras map[string]interface{})

RunInsertQuery inserts a new row in the table.

func RunSelectQuery

func RunSelectQuery(t *testing.T, extras map[string]interface{})

RunSelectQuery runs a SELECT query on the test DB.

func RunServer

func RunServer(t testing.TB, serverAddr, serverPort string) error

RunServer runs a postgres server in a docker container

func RunUpdateQuery

func RunUpdateQuery(t *testing.T, extras map[string]interface{})

RunUpdateQuery runs an UPDATE query on the test DB.

Types

type DummyTable

type DummyTable struct {
	bun.BaseModel `bun:"table:dummy,alias:d"`

	ID  int64 `bun:",pk,autoincrement"`
	Foo string
}

DummyTable defines a table schema, so that `bun` module can generate queries for it.

Jump to

Keyboard shortcuts

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