fix some tests
This commit is contained in:
parent
76fee8b2a8
commit
dbb2220ce7
|
@ -23,6 +23,7 @@ type Interface interface {
|
||||||
CreateIndexes(bean interface{}) error
|
CreateIndexes(bean interface{}) error
|
||||||
CreateUniques(bean interface{}) error
|
CreateUniques(bean interface{}) error
|
||||||
Decr(column string, arg ...interface{}) *Session
|
Decr(column string, arg ...interface{}) *Session
|
||||||
|
Desc(...string) *Session
|
||||||
Delete(interface{}) (int64, error)
|
Delete(interface{}) (int64, error)
|
||||||
Distinct(columns ...string) *Session
|
Distinct(columns ...string) *Session
|
||||||
DropIndexes(bean interface{}) error
|
DropIndexes(bean interface{}) error
|
||||||
|
@ -40,6 +41,7 @@ type Interface interface {
|
||||||
IsTableExist(beanOrTableName interface{}) (bool, error)
|
IsTableExist(beanOrTableName interface{}) (bool, error)
|
||||||
Iterate(interface{}, IterFunc) error
|
Iterate(interface{}, IterFunc) error
|
||||||
Limit(int, ...int) *Session
|
Limit(int, ...int) *Session
|
||||||
|
NoAutoCondition(...bool) *Session
|
||||||
NotIn(string, ...interface{}) *Session
|
NotIn(string, ...interface{}) *Session
|
||||||
Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
|
Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
|
||||||
Omit(columns ...string) *Session
|
Omit(columns ...string) *Session
|
||||||
|
@ -58,6 +60,7 @@ type Interface interface {
|
||||||
Table(tableNameOrBean interface{}) *Session
|
Table(tableNameOrBean interface{}) *Session
|
||||||
Unscoped() *Session
|
Unscoped() *Session
|
||||||
Update(bean interface{}, condiBeans ...interface{}) (int64, error)
|
Update(bean interface{}, condiBeans ...interface{}) (int64, error)
|
||||||
|
UseBool(...string) *Session
|
||||||
Where(interface{}, ...interface{}) *Session
|
Where(interface{}, ...interface{}) *Session
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +89,7 @@ type EngineInterface interface {
|
||||||
SetTZDatabase(tz *time.Location)
|
SetTZDatabase(tz *time.Location)
|
||||||
SetTZLocation(tz *time.Location)
|
SetTZLocation(tz *time.Location)
|
||||||
ShowSQL(show ...bool)
|
ShowSQL(show ...bool)
|
||||||
|
Sync(...interface{}) error
|
||||||
Sync2(...interface{}) error
|
Sync2(...interface{}) error
|
||||||
StoreEngine(storeEngine string) *Session
|
StoreEngine(storeEngine string) *Session
|
||||||
TableInfo(bean interface{}) *Table
|
TableInfo(bean interface{}) *Table
|
||||||
|
|
|
@ -219,7 +219,7 @@ func TestInsertDefault(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var di2 = DefaultInsert{Name: "test"}
|
var di2 = DefaultInsert{Name: "test"}
|
||||||
_, err = testEngine.Omit(testEngine.ColumnMapper.Obj2Table("Status")).Insert(&di2)
|
_, err = testEngine.Omit(testEngine.GetColumnMapper().Obj2Table("Status")).Insert(&di2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ func TestInsertDefault2(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var di2 = DefaultInsert2{Name: "test"}
|
var di2 = DefaultInsert2{Name: "test"}
|
||||||
_, err = testEngine.Omit(testEngine.ColumnMapper.Obj2Table("CheckTime")).Insert(&di2)
|
_, err = testEngine.Omit(testEngine.GetColumnMapper().Obj2Table("CheckTime")).Insert(&di2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ type ForUpdate struct {
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupForUpdate(engine *Engine) error {
|
func setupForUpdate(engine EngineInterface) error {
|
||||||
v := new(ForUpdate)
|
v := new(ForUpdate)
|
||||||
err := testEngine.DropTables(v)
|
err := testEngine.DropTables(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -110,7 +110,7 @@ func setupForUpdate(engine *Engine) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestForUpdate(t *testing.T) {
|
func TestForUpdate(t *testing.T) {
|
||||||
if testEngine.DriverName() != "mysql" && testEngine.DriverName() != "mymysql" {
|
if testEngine.Dialect().DriverName() != "mysql" && testEngine.Dialect().DriverName() != "mymysql" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,8 +517,8 @@ func TestUpdate1(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
col2 := &UpdateMustCols{col1.Id, true, ""}
|
col2 := &UpdateMustCols{col1.Id, true, ""}
|
||||||
boolStr := testEngine.ColumnMapper.Obj2Table("Bool")
|
boolStr := testEngine.GetColumnMapper().Obj2Table("Bool")
|
||||||
stringStr := testEngine.ColumnMapper.Obj2Table("String")
|
stringStr := testEngine.GetColumnMapper().Obj2Table("String")
|
||||||
_, err = testEngine.ID(col2.Id).MustCols(boolStr, stringStr).Update(col2)
|
_, err = testEngine.ID(col2.Id).MustCols(boolStr, stringStr).Update(col2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -559,7 +559,7 @@ func TestUpdateIncrDecr(t *testing.T) {
|
||||||
_, err := testEngine.Insert(col1)
|
_, err := testEngine.Insert(col1)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
colName := testEngine.ColumnMapper.Obj2Table("Cnt")
|
colName := testEngine.GetColumnMapper().Obj2Table("Cnt")
|
||||||
|
|
||||||
cnt, err := testEngine.ID(col1.Id).Incr(colName).Update(col1)
|
cnt, err := testEngine.ID(col1.Id).Incr(colName).Update(col1)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -759,21 +759,21 @@ func TestUpdateUpdated(t *testing.T) {
|
||||||
func TestUpdateSameMapper(t *testing.T) {
|
func TestUpdateSameMapper(t *testing.T) {
|
||||||
assert.NoError(t, prepareEngine())
|
assert.NoError(t, prepareEngine())
|
||||||
|
|
||||||
oldMapper := testEngine.ColumnMapper
|
oldMapper := testEngine.GetColumnMapper()
|
||||||
testEngine.unMapType(rValue(new(Userinfo)).Type())
|
testEngine.UnMapType(rValue(new(Userinfo)).Type())
|
||||||
testEngine.unMapType(rValue(new(Condi)).Type())
|
testEngine.UnMapType(rValue(new(Condi)).Type())
|
||||||
testEngine.unMapType(rValue(new(Article)).Type())
|
testEngine.UnMapType(rValue(new(Article)).Type())
|
||||||
testEngine.unMapType(rValue(new(UpdateAllCols)).Type())
|
testEngine.UnMapType(rValue(new(UpdateAllCols)).Type())
|
||||||
testEngine.unMapType(rValue(new(UpdateMustCols)).Type())
|
testEngine.UnMapType(rValue(new(UpdateMustCols)).Type())
|
||||||
testEngine.unMapType(rValue(new(UpdateIncr)).Type())
|
testEngine.UnMapType(rValue(new(UpdateIncr)).Type())
|
||||||
testEngine.SetMapper(core.SameMapper{})
|
testEngine.SetMapper(core.SameMapper{})
|
||||||
defer func() {
|
defer func() {
|
||||||
testEngine.unMapType(rValue(new(Userinfo)).Type())
|
testEngine.UnMapType(rValue(new(Userinfo)).Type())
|
||||||
testEngine.unMapType(rValue(new(Condi)).Type())
|
testEngine.UnMapType(rValue(new(Condi)).Type())
|
||||||
testEngine.unMapType(rValue(new(Article)).Type())
|
testEngine.UnMapType(rValue(new(Article)).Type())
|
||||||
testEngine.unMapType(rValue(new(UpdateAllCols)).Type())
|
testEngine.UnMapType(rValue(new(UpdateAllCols)).Type())
|
||||||
testEngine.unMapType(rValue(new(UpdateMustCols)).Type())
|
testEngine.UnMapType(rValue(new(UpdateMustCols)).Type())
|
||||||
testEngine.unMapType(rValue(new(UpdateIncr)).Type())
|
testEngine.UnMapType(rValue(new(UpdateIncr)).Type())
|
||||||
testEngine.SetMapper(oldMapper)
|
testEngine.SetMapper(oldMapper)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -943,8 +943,8 @@ func TestUpdateSameMapper(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
col2 := &UpdateMustCols{col1.Id, true, ""}
|
col2 := &UpdateMustCols{col1.Id, true, ""}
|
||||||
boolStr := testEngine.ColumnMapper.Obj2Table("Bool")
|
boolStr := testEngine.GetColumnMapper().Obj2Table("Bool")
|
||||||
stringStr := testEngine.ColumnMapper.Obj2Table("String")
|
stringStr := testEngine.GetColumnMapper().Obj2Table("String")
|
||||||
_, err = testEngine.ID(col2.Id).MustCols(boolStr, stringStr).Update(col2)
|
_, err = testEngine.ID(col2.Id).MustCols(boolStr, stringStr).Update(col2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
|
Loading…
Reference in New Issue