🔥A cross-language distributed transaction manager. Support xa, tcc, saga, transactional messages. 跨语言分布式事务管理器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

41 lines
765 B

package common
import (
"testing"
"github.com/go-playground/assert/v2"
)
type testConfig struct {
Mysql map[string]string `yaml:"Mysql"`
}
var config = testConfig{}
func init() {
InitConfig(GetProjectDir(), &config)
config.Mysql["database"] = ""
}
func TestDb(t *testing.T) {
db := DbGet(config.Mysql)
err := func() (rerr error) {
defer P2E(&rerr)
dbr := db.NoMust().Exec("select a")
assert.NotEqual(t, nil, dbr.Error)
db.Must().Exec("select a")
return nil
}()
assert.NotEqual(t, nil, err)
sdb := db.ToSQLDB()
db = SQLDB2DB(sdb)
}
func TestDbAlone(t *testing.T) {
db, con := DbAlone(config.Mysql)
dbr := db.Exec("select 1")
assert.Equal(t, nil, dbr.Error)
con.Close()
dbr = db.Exec("select 1")
assert.NotEqual(t, nil, dbr.Error)
}