testutils

package
v4.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPgDSN default PostgreSQL test connection string
	DefaultPgDSN = "postgres://postgres:yzy123@" + dbIp + ":5432/test?sslmode=disable"
	// DefaultMySQLDSN default MySQL test connection string
	DefaultMySQLDSN = "remote:123456@tcp(" + dbIp + ":3306)/test?charset=utf8mb4&parseTime=True"
)
View Source
var TestMySQLDSN = DefaultMySQLDSN

TestMySQLDSN current MySQL test connection string

View Source
var TestPgDSN = DefaultPgDSN

TestPgDSN current PostgreSQL test connection string

Functions

func CleanupTestDB added in v4.1.5

func CleanupTestDB(db *sql.DB, tables ...string) error

CleanupTestDB 清理测试数据库

func SetupTestDB added in v4.1.5

func SetupTestDB(config TestDBConfig) (*sql.DB, error)

SetupTestDB 设置测试数据库

Types

type TestDBConfig added in v4.1.5

type TestDBConfig struct {
	Driver   string
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
}

TestDBConfig 测试数据库配置

func DefaultMySQLConfig added in v4.1.5

func DefaultMySQLConfig() TestDBConfig

DefaultMySQLConfig 返回默认的MySQL测试配置

func DefaultPostgresConfig added in v4.1.5

func DefaultPostgresConfig() TestDBConfig

DefaultPostgresConfig 返回默认的PostgreSQL测试配置

func (TestDBConfig) DSN added in v4.1.5

func (c TestDBConfig) DSN() string

DSN 返回数据库连接字符串

Jump to

Keyboard shortcuts

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