dbtestutil

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: AGPL-3.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpOnFailure added in v2.2.0

func DumpOnFailure(t testing.TB, connectionURL string)

DumpOnFailure exports the database referenced by connectionURL to a file corresponding to the current test, with a suffix indicating the time the test was run. To import this into a new database (assuming you have already run make test-postgres-docker):

  • Create a new test database: go run ./scripts/migrate-ci/main.go and note the database name it outputs
  • Import the file into the above database: psql 'postgres://postgres:postgres@127.0.0.1:5432/<dbname>?sslmode=disable' -f <path to file.test.sql>
  • Run a dev server against that database: ./scripts/coder-dev.sh server --postgres-url='postgres://postgres:postgres@127.0.0.1:5432/<dbname>?sslmode=disable'

func NewDB

func NewDB(t testing.TB, opts ...Option) (database.Store, pubsub.Pubsub)

func NewDBWithSQLDB added in v2.3.1

func NewDBWithSQLDB(t testing.TB, opts ...Option) (database.Store, pubsub.Pubsub, *sql.DB)

func WillUsePostgres

func WillUsePostgres() bool

WillUsePostgres returns true if a call to NewDB() will return a real, postgres-backed Store and Pubsub.

Types

type Option added in v2.2.0

type Option func(*options)

func WithDumpOnFailure added in v2.2.0

func WithDumpOnFailure() Option

WithDumpOnFailure will dump the entire database on test failure.

func WithTimezone added in v2.2.0

func WithTimezone(tz string) Option

WithTimezone sets the database to the defined timezone.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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