testutil

package
v1.2.0-main Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides shared test database utilities

Index

Constants

View Source
const (
	StrategyLocal    = "local"
	StrategyTemplate = "template"
)

Variables

This section is empty.

Functions

func CloseDB

func CloseDB(db *gorm.DB)

CloseDB closes the database connection

func CreateTestDB

func CreateTestDB(ctx context.Context, log *logrus.Logger, prefix string, initDB InitDBFunc) (*config.Config, string, *gorm.DB)

CreateTestDB creates a temporary test database and returns the config, db name, and gorm.DB connection. The caller is responsible for running migrations and creating the appropriate store.

func DeleteTestDB

func DeleteTestDB(ctx context.Context, log *logrus.Logger, cfg *config.Config, db *gorm.DB, dbName string, initDB InitDBFunc)

DeleteTestDB drops the test database

Types

type InitDBFunc

type InitDBFunc func(cfg *config.Config, log *logrus.Logger) (*gorm.DB, error)

InitDBFunc is a function that initializes a database connection

Jump to

Keyboard shortcuts

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