utils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 6 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNoErr

func AssertNoErr(t *testing.T, err error)

AssertNoErr makes current test case fatal if it receives a non-nil error

func AutoMigrate

func AutoMigrate(db *gorm.DB, givenTables ...interface{})

AutoMigrate receives table arguments and create or update their table structure in database.

func GetTestDB

func GetTestDB() *gorm.DB

func PrepareDBAndTables

func PrepareDBAndTables(tables ...interface{}) *gorm.DB

PrepareDBAndTables prepare given tables cleanly and return a test database instance

func ResetDBTables

func ResetDBTables(db *gorm.DB, tables ...interface{})

ResetDBTables reset given tables.

func TestDB

func TestDB() *gorm.DB

TestDB initialize a db for testing

func Truncate

func Truncate(db *gorm.DB, givenTables ...interface{})

Truncate receives table arguments and truncate their content in database.

Types

type Migratable

type Migratable interface {
	AfterMigrate(db *gorm.DB) error
}

Migratable defines interface for implementing post-migration actions such as adding constraints that arent's supported by Gorm's struct tags. This function must be idempotent, since it will most likely be executed multiple times.

Jump to

Keyboard shortcuts

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