dbtest

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTables

func ClearTables(t *testing.T, db *gorm.DB, tables ...any) error

ClearTables removes all rows from given tables.

func New

func New(ctx context.Context, t *testing.T, suite string, tables ...any) (*sqlx.DB, *gorm.DB)

func NewDB

func NewDB(ctx context.Context, t *testing.T, suite string, tables ...any) *gorm.DB

func NewMockDB

func NewMockDB() (*gorm.DB, sqlmock.Sqlmock)

Types

type Hooks

type Hooks struct {
	T *testing.T
}

func (*Hooks) After

func (h *Hooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error)

After hook will get the timestamp registered on the Before hook and print the elapsed time

func (*Hooks) Before

func (h *Hooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error)

Before hook will print the query with it's args and return the context with the timestamp

Jump to

Keyboard shortcuts

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