test: fix test
This commit is contained in:
parent
6ae2f6b00a
commit
678adb3e2f
@ -171,16 +171,17 @@ func TestPreparedStmtInTransaction(t *testing.T) {
|
|||||||
|
|
||||||
func TestPreparedStmtReset(t *testing.T) {
|
func TestPreparedStmtReset(t *testing.T) {
|
||||||
tx := DB.Session(&gorm.Session{PrepareStmt: true})
|
tx := DB.Session(&gorm.Session{PrepareStmt: true})
|
||||||
|
|
||||||
|
user := *GetUser("prepared_stmt_reset", Config{})
|
||||||
|
tx = tx.Create(&user)
|
||||||
|
|
||||||
pdb, ok := tx.ConnPool.(*gorm.PreparedStmtDB)
|
pdb, ok := tx.ConnPool.(*gorm.PreparedStmtDB)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("should assign PreparedStatement Manager back to database when using PrepareStmt mode")
|
t.Fatalf("should assign PreparedStatement Manager back to database when using PrepareStmt mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
user := *GetUser("prepared_stmt_reset", Config{})
|
|
||||||
tx.Create(&user)
|
|
||||||
|
|
||||||
pdb.Mux.Lock()
|
pdb.Mux.Lock()
|
||||||
if len(pdb.PreparedSQL) == 0 || len(pdb.Stmts) == 0 {
|
if len(pdb.Stmts) == 0 {
|
||||||
pdb.Mux.Unlock()
|
pdb.Mux.Unlock()
|
||||||
t.Fatalf("prepared stmt can not be empty")
|
t.Fatalf("prepared stmt can not be empty")
|
||||||
}
|
}
|
||||||
@ -189,7 +190,7 @@ func TestPreparedStmtReset(t *testing.T) {
|
|||||||
pdb.Reset()
|
pdb.Reset()
|
||||||
pdb.Mux.Lock()
|
pdb.Mux.Lock()
|
||||||
defer pdb.Mux.Unlock()
|
defer pdb.Mux.Unlock()
|
||||||
if len(pdb.PreparedSQL) != 0 || len(pdb.Stmts) != 0 {
|
if len(pdb.Stmts) != 0 {
|
||||||
t.Fatalf("prepared stmt should be empty")
|
t.Fatalf("prepared stmt should be empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user