Documentation
¶
Overview ¶
Package xormadapter. xormadapter.go - Adapts a *xorm.Engine to the dbtestkit.Engine interface. Users of xorm (casdoor, etc.) can pass an instance of this adapter to their WithEngineInitializer callback.
Example:
import (
"github.com/seyallius/gopherbox/dbtestkit"
"github.com/seyallius/gopherbox/dbtestkit/xormadapter"
"github.com/xorm-io/xorm"
)
dbtestkit.Run(m,
dbtestkit.WithDriver(mysql.New()),
dbtestkit.WithEngineInitializer(func(env *dbtestkit.Environment) (dbtestkit.Engine, error) {
eng, err := xorm.NewEngine("mysql", env.DSN())
if err != nil {
return nil, err
}
return xormadapter.New(eng), nil
}),
...
)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter wraps a *xorm.Engine to satisfy dbtestkit.Engine.
func New ¶
New returns an Adapter wrapping the given *xorm.Engine.
The Adapter does NOT take ownership of the engine — the caller is responsible for closing it (which dbtestkit does via Engine.Close()).
func (*Adapter) ClearCache ¶
ClearCache implements dbtestkit.Engine. Forwards to xorm.Engine.ClearCache, which flushes the ORM-level Ristretto store. Safe to call even if caching is disabled (ClearCache is a no-op in that case).
func (*Adapter) Engine ¶
Engine returns the underlying *xorm.Engine, should the caller need to pass it to ORM-specific helpers (e.g. Sync2).