mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 15:04:45 +08:00
40 lines
827 B
Go
40 lines
827 B
Go
package sysmodule_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/duanhf2012/origin/sysmodule"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
)
|
|
|
|
func TestDBModule(t *testing.T) {
|
|
db := sysmodule.DBModule{
|
|
URL: "192.168.0.5:3306",
|
|
UserName: "root",
|
|
Password: "Root!!2018",
|
|
DBName: "QuantFundsDB",
|
|
}
|
|
db.Connect(100)
|
|
|
|
res := db.Query("select * from tbl_fun_heelthrow where id >= 1")
|
|
if res.Err != nil {
|
|
t.Error(res.Err)
|
|
}
|
|
out := []struct {
|
|
Addtime int64 `json:"addtime"`
|
|
Tname string `json:"tname"`
|
|
Uuid string `json:"uuid,omitempty"`
|
|
AAAA string `json:"xxx"`
|
|
}{}
|
|
err := res.SetSpecificTag("json").SetBlurMode(true).UnMarshal(&out)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
sres := db.SyncQuery("select * from tbl_fun_heelthrow where id >= 1")
|
|
res = sres.Get(1000)
|
|
if res.Err != nil {
|
|
t.Error(res.Err)
|
|
}
|
|
}
|