mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-21 04:04:43 +08:00
添加db测试文件
This commit is contained in:
39
sysmodule/DBModule_test.go
Normal file
39
sysmodule/DBModule_test.go
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
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()
|
||||||
|
|
||||||
|
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:"-"`
|
||||||
|
}{}
|
||||||
|
err := sysmodule.NewSQLDecoder(res).SetSpecificTag("json").SetStrictMode(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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/duanhf2012/origin/sysmodule"
|
"github.com/duanhf2012/origin/sysmodule"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHttpClientPoolModule(t *testing.T) {
|
func TestHttpClientPoolModule(t *testing.T) {
|
||||||
@@ -28,34 +27,3 @@ func TestHttpClientPoolModule(t *testing.T) {
|
|||||||
fmt.Println(rsp1.Status)
|
fmt.Println(rsp1.Status)
|
||||||
fmt.Println(string(rsp1.Body))
|
fmt.Println(string(rsp1.Body))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDBModule(t *testing.T) {
|
|
||||||
db := sysmodule.DBModule{
|
|
||||||
URL: "192.168.0.5:3306",
|
|
||||||
UserName: "root",
|
|
||||||
Password: "Root!!2018",
|
|
||||||
DBName: "QuantFundsDB",
|
|
||||||
}
|
|
||||||
db.Connect()
|
|
||||||
|
|
||||||
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:"-"`
|
|
||||||
}{}
|
|
||||||
err := sysmodule.NewSQLDecoder(res).SetSpecificTag("json").SetStrictMode(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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user