gormtestsupport

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

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package gormtestsupport provides all the required functions to manage the lifecycle and common operations against our gorm database in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTestSuite

type DBTestSuite struct {
	suite.Suite
	Configuration   *config.ConfigurationData
	DB              *gorm.DB
	Application     application.Application
	CleanTest       func() error
	CleanSuite      func() error
	SetupSubtest    func()
	TearDownSubtest func()
	Ctx             context.Context
	Graph           *graph.TestGraph
	Wrappers        factorymanager.FactoryWrappers
	// contains filtered or unexported fields
}

DBTestSuite is a base for tests using a gorm db

func NewDBTestSuite

func NewDBTestSuite() DBTestSuite

NewDBTestSuite instantiates a new DBTestSuite

func (*DBTestSuite) DisableGormCallbacks

func (s *DBTestSuite) DisableGormCallbacks() func()

DisableGormCallbacks will turn off gorm's automatic setting of `created_at` and `updated_at` columns. Call this function and make sure to `defer` the returned function.

resetFn := DisableGormCallbacks()
defer resetFn()

func (*DBTestSuite) NewTestGraph

func (s *DBTestSuite) NewTestGraph(t *testing.T) graph.TestGraph

func (*DBTestSuite) OverrideConfig

func (s *DBTestSuite) OverrideConfig(envVar string, value string)

OverrideConfig allows the temporary overriding of a configuration value for the duration of a single test

func (*DBTestSuite) PopulateDBTestSuite

func (s *DBTestSuite) PopulateDBTestSuite(ctx context.Context)

PopulateDBTestSuite populates the DB with common values

func (*DBTestSuite) ResetFactories

func (s *DBTestSuite) ResetFactories()

ResetFactories resets all factories to default, and resets all overridden factory configurations.

func (*DBTestSuite) Run

func (s *DBTestSuite) Run(name string, subtest func()) bool

Run overrides the default behaviour of the Suite.Run method, in order to run the SetupSubtest and TearDownSubtest methods for each subtest

func (*DBTestSuite) SetupSuite

func (s *DBTestSuite) SetupSuite()

SetupSuite implements suite.SetupAllSuite

func (*DBTestSuite) SetupTest

func (s *DBTestSuite) SetupTest()

SetupTest implements suite.SetupTest

func (*DBTestSuite) TearDownSuite

func (s *DBTestSuite) TearDownSuite()

TearDownSuite implements suite.TearDownAllSuite

func (*DBTestSuite) TearDownTest

func (s *DBTestSuite) TearDownTest()

TearDownTest implements suite.TearDownTest

func (*DBTestSuite) WrapFactory

func (s *DBTestSuite) WrapFactory(identifier string, constructor wrapper.FactoryWrapperConstructor, initializer wrapper.FactoryWrapperInitializer)

WrapFactory replaces a default factory with the specified factory. This function is recommended to be used during tests where the default behaviour of a factory needs to be overridden

Directories

Path Synopsis
Package benchmark provides all the required functions to manage the lifecycle and common operations against our gorm database in benchmarks.
Package benchmark provides all the required functions to manage the lifecycle and common operations against our gorm database in benchmarks.

Jump to

Keyboard shortcuts

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