Documentation
¶
Index ¶
- Variables
- func ConnectForTest(ctx context.Context, addr string) (db *gorm.DB, err error)
- func IsForeignKeyConstraintError(err error) bool
- func IsUniqueConstraintError(err error) bool
- func NewGorm(ctx context.Context, opts ...Option) (db *gorm.DB, err error)
- func RunContainerForTest(ctx context.Context, queriesFile string) (*gnomock.Container, error)
- func UpdateID(db *gorm.DB)
- type MysqlOption
- type Option
- func WithAutoMigrate(autoMigrate bool) Option
- func WithDebug(debug bool) Option
- func WithDialect(dialect string) Option
- func WithMysqlCharset(charset string) Option
- func WithMysqlHost(host string) Option
- func WithMysqlName(name string) Option
- func WithMysqlOptions(opts ...MysqlOption) Option
- func WithMysqlPassword(password string) Option
- func WithMysqlPort(port int) Option
- func WithMysqlUser(user string) Option
- func WithSqliteName(name string) Option
- func WithSqliteOptions(opts ...SqliteOption) Option
- type SqliteOption
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoDatabaseDsn = errors.New("no database dsn")
)
Functions ¶
func ConnectForTest ¶
func IsForeignKeyConstraintError ¶
IsForeignKeyConstraintError reports if the error resulted from a DB FK constraint violation. e.g. parent row does not exist.
func IsUniqueConstraintError ¶
IsUniqueConstraintError reports if the error resulted from a DB uniqueness constraint violation. e.g. duplicate value in unique index.
func RunContainerForTest ¶
Types ¶
type MysqlOption ¶
type MysqlOption func(*mysqlOptions)
type Option ¶
type Option func(*options)
Option 定义参数项
func WithMysqlCharset ¶
func WithMysqlHost ¶
func WithMysqlName ¶
func WithMysqlOptions ¶
func WithMysqlOptions(opts ...MysqlOption) Option
WithMysqlOptions 设定 mysqlOptions
func WithMysqlPassword ¶
func WithMysqlPort ¶
func WithSqliteName ¶
func WithSqliteOptions ¶
func WithSqliteOptions(opts ...SqliteOption) Option
WithSqliteOptions 设定 sqliteOptions
type SqliteOption ¶
type SqliteOption func(*sqliteOptions)
Click to show internal directories.
Click to hide internal directories.