fix tests

This commit is contained in:
Lunny Xiao 2017-05-30 20:29:15 +08:00
parent 1b8d08d531
commit 19b1270f7b
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
5 changed files with 20 additions and 5 deletions

View File

@ -143,7 +143,6 @@ func (engine *Engine) Quote(value string) string {
// QuoteTo quotes string and writes into the buffer
func (engine *Engine) QuoteTo(buf *bytes.Buffer, value string) {
if buf == nil {
return
}
@ -781,6 +780,12 @@ func (engine *Engine) Having(conditions string) *Session {
return session.Having(conditions)
}
func (engine *Engine) unMapType(t reflect.Type) {
engine.mutex.Lock()
defer engine.mutex.Unlock()
delete(engine.Tables, t)
}
func (engine *Engine) autoMapType(v reflect.Value) (*core.Table, error) {
t := v.Type()
engine.mutex.Lock()

View File

@ -273,10 +273,14 @@ func TestHaving(t *testing.T) {
func TestOrderSameMapper(t *testing.T) {
assert.NoError(t, prepareEngine())
testEngine.unMapType(rValue(new(Userinfo)).Type())
mapper := testEngine.TableMapper
testEngine.SetTableMapper(core.SameMapper{})
testEngine.SetMapper(core.SameMapper{})
defer func() {
testEngine.SetTableMapper(mapper)
testEngine.unMapType(rValue(new(Userinfo)).Type())
testEngine.SetMapper(mapper)
}()
assertSync(t, new(Userinfo))
@ -300,10 +304,13 @@ func TestOrderSameMapper(t *testing.T) {
func TestHavingSameMapper(t *testing.T) {
assert.NoError(t, prepareEngine())
testEngine.unMapType(rValue(new(Userinfo)).Type())
mapper := testEngine.TableMapper
testEngine.SetTableMapper(core.SameMapper{})
testEngine.SetMapper(core.SameMapper{})
defer func() {
testEngine.SetTableMapper(mapper)
testEngine.unMapType(rValue(new(Userinfo)).Type())
testEngine.SetMapper(mapper)
}()
assertSync(t, new(Userinfo))

1
test_mysql.sh Executable file
View File

@ -0,0 +1 @@
go test -db=mysql -conn_str="root:@/xorm_test"

1
test_postgres.sh Executable file
View File

@ -0,0 +1 @@
go test -db=postgres -conn_str="dbname=xorm_test sslmode=disable"

1
test_sqlite.sh Executable file
View File

@ -0,0 +1 @@
go test -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc"