mirror of
https://github.com/duanhf2012/origin.git
synced 2026-03-15 21:37:31 +08:00
提交单元测试
This commit is contained in:
@@ -503,13 +503,13 @@ func (slf *DataSetList) UnMarshal(args ...interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v.Elem().Kind() == reflect.Struct {
|
if v.Elem().Kind() == reflect.Struct {
|
||||||
err := slf.RowData2interface(0, slf.dataSetList[slf.currentDataSetIdx].RowInfo, v)
|
err := slf.rowData2interface(0, slf.dataSetList[slf.currentDataSetIdx].RowInfo, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if v.Elem().Kind() == reflect.Slice {
|
if v.Elem().Kind() == reflect.Slice {
|
||||||
err := slf.Slice2interface(out)
|
err := slf.slice2interface(out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -521,7 +521,7 @@ func (slf *DataSetList) UnMarshal(args ...interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (slf *DataSetList) Slice2interface(in interface{}) error {
|
func (slf *DataSetList) slice2interface(in interface{}) error {
|
||||||
length := slf.dataSetList[slf.currentDataSetIdx].rowNum
|
length := slf.dataSetList[slf.currentDataSetIdx].rowNum
|
||||||
if length == 0 {
|
if length == 0 {
|
||||||
return nil
|
return nil
|
||||||
@@ -542,7 +542,7 @@ func (slf *DataSetList) Slice2interface(in interface{}) error {
|
|||||||
idxv = idxv.Addr()
|
idxv = idxv.Addr()
|
||||||
}
|
}
|
||||||
|
|
||||||
err := slf.RowData2interface(i, slf.dataSetList[slf.currentDataSetIdx].RowInfo, idxv)
|
err := slf.rowData2interface(i, slf.dataSetList[slf.currentDataSetIdx].RowInfo, idxv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -551,7 +551,7 @@ func (slf *DataSetList) Slice2interface(in interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (slf *DataSetList) RowData2interface(rowIdx int, m map[string][]interface{}, v reflect.Value) error {
|
func (slf *DataSetList) rowData2interface(rowIdx int, m map[string][]interface{}, v reflect.Value) error {
|
||||||
t := v.Type()
|
t := v.Type()
|
||||||
val := v.Elem()
|
val := v.Elem()
|
||||||
typ := t.Elem()
|
typ := t.Elem()
|
||||||
@@ -573,7 +573,7 @@ func (slf *DataSetList) RowData2interface(rowIdx int, m map[string][]interface{}
|
|||||||
columnData, ok := m[vtag]
|
columnData, ok := m[vtag]
|
||||||
if ok == false {
|
if ok == false {
|
||||||
if !slf.blur {
|
if !slf.blur {
|
||||||
return fmt.Errorf("Cannot find filed name %s", vtag[0])
|
return fmt.Errorf("Cannot find filed name %s", vtag)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ func TestDBModule(t *testing.T) {
|
|||||||
|
|
||||||
db.Init(100, "192.168.0.5:3306", "root", "Root!!2018", "QuantFundsDB")
|
db.Init(100, "192.168.0.5:3306", "root", "Root!!2018", "QuantFundsDB")
|
||||||
db.OnInit()
|
db.OnInit()
|
||||||
res := db.Query("select * from tbl_fun_heelthrow where id >= 1")
|
res, err := db.QueryEx("select * from tbl_fun_heelthrow where id >= 1")
|
||||||
if res.Err != nil {
|
if err != nil {
|
||||||
t.Error(res.Err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
out := []struct {
|
out := []struct {
|
||||||
Addtime int64 `json:"addtime"`
|
Addtime int64 `json:"addtime"`
|
||||||
@@ -25,15 +25,15 @@ func TestDBModule(t *testing.T) {
|
|||||||
Uuid string `json:"uuid,omitempty"`
|
Uuid string `json:"uuid,omitempty"`
|
||||||
AAAA string `json:"xxx"`
|
AAAA string `json:"xxx"`
|
||||||
}{}
|
}{}
|
||||||
err := res.UnMarshal(&out)
|
err = res.UnMarshal(&out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sres := db.SyncQuery("select * from tbl_fun_heelthrow where id >= 1")
|
sres := db.SyncQuery("select * from tbl_fun_heelthrow where id >= 1")
|
||||||
res = sres.Get(2000)
|
res, err = sres.Get(2000)
|
||||||
if res.Err != nil {
|
if err != nil {
|
||||||
t.Error(res.Err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
out2 := []struct {
|
out2 := []struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user