提交单元测试

This commit is contained in:
boyce
2019-03-18 12:58:36 +08:00
parent aeefc6385c
commit 00b66bf24b
2 changed files with 13 additions and 13 deletions

View File

@@ -503,13 +503,13 @@ func (slf *DataSetList) UnMarshal(args ...interface{}) error {
}
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 {
return err
}
}
if v.Elem().Kind() == reflect.Slice {
err := slf.Slice2interface(out)
err := slf.slice2interface(out)
if err != nil {
return err
}
@@ -521,7 +521,7 @@ func (slf *DataSetList) UnMarshal(args ...interface{}) error {
return nil
}
func (slf *DataSetList) Slice2interface(in interface{}) error {
func (slf *DataSetList) slice2interface(in interface{}) error {
length := slf.dataSetList[slf.currentDataSetIdx].rowNum
if length == 0 {
return nil
@@ -542,7 +542,7 @@ func (slf *DataSetList) Slice2interface(in interface{}) error {
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 {
return err
}
@@ -551,7 +551,7 @@ func (slf *DataSetList) Slice2interface(in interface{}) error {
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()
val := v.Elem()
typ := t.Elem()
@@ -573,7 +573,7 @@ func (slf *DataSetList) RowData2interface(rowIdx int, m map[string][]interface{}
columnData, ok := m[vtag]
if ok == false {
if !slf.blur {
return fmt.Errorf("Cannot find filed name %s", vtag[0])
return fmt.Errorf("Cannot find filed name %s", vtag)
}
continue
}

View File

@@ -15,9 +15,9 @@ func TestDBModule(t *testing.T) {
db.Init(100, "192.168.0.5:3306", "root", "Root!!2018", "QuantFundsDB")
db.OnInit()
res := db.Query("select * from tbl_fun_heelthrow where id >= 1")
if res.Err != nil {
t.Error(res.Err)
res, err := db.QueryEx("select * from tbl_fun_heelthrow where id >= 1")
if err != nil {
t.Error(err)
}
out := []struct {
Addtime int64 `json:"addtime"`
@@ -25,15 +25,15 @@ func TestDBModule(t *testing.T) {
Uuid string `json:"uuid,omitempty"`
AAAA string `json:"xxx"`
}{}
err := res.UnMarshal(&out)
err = res.UnMarshal(&out)
if err != nil {
t.Error(err)
}
sres := db.SyncQuery("select * from tbl_fun_heelthrow where id >= 1")
res = sres.Get(2000)
if res.Err != nil {
t.Error(res.Err)
res, err = sres.Get(2000)
if err != nil {
t.Error(err)
}
out2 := []struct {