postgres_test

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GithubActionsOverride = func(cfg *Config) {
	if os.Getenv("COVERALLS_TOKEN") != "" {
		cfg.Host = "db"
		cfg.ProjectPath = "/app"
		cfg.Port = 5432
	}
}

TODO Find a better way of finding out if this is being executed inside a GitHub Action. GithubActionsOverride is function for database options Config override when using GH Actions.

Functions

func Initialize

func Initialize(cfg Config)

Initialize initializes new global builder with passed config.

func NewBuilder added in v0.3.0

func NewBuilder(cfg Config) *fixturesBuilder

NewBuilder creates a new builder

func RebuildDatabase

func RebuildDatabase()

RebuildDatabase uses builder rebuildDB to drop and recreate test database from template.

func TemplateDB

func TemplateDB() *gorm.DB

TemplateDB returns instance of gORM template DB

func TestDB

func TestDB() *gorm.DB

TestDB returns instance of gORM test DB

func TestDSN added in v0.2.1

func TestDSN() string

TestDSN returns DSN for test DB

Types

type Config

type Config struct {
	// Host is the hostname of the test database service.
	Host string
	// Port is the port of the test database service.
	Port int16
	// User defined to connect to database.
	User string
	// Password defined to connect to database.
	Password string
	// MainDirectory is the main directory of a project - it's needed to cleanup path for finding fixtures file
	MainDirectory string
	// FixturesPath is path to fixture files for preloading. Default is set to "/testdata/fixtures".
	FixturesPath string
	// ProjectPath should be fixed path to the project. It's dynamically added when empty.
	ProjectPath string
	// OverrideFunc overrides created Config options after initialization.
	OverrideFunc func(cfg *Config)
	// Migrations are migrations to run during initialization.
	Migrations []migrate.Migration
}

Config represents database config for test database service.

Jump to

Keyboard shortcuts

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