test: fix test

This commit is contained in:
a631807682 2022-10-19 14:27:35 +08:00
parent 6ae2f6b00a
commit 678adb3e2f
No known key found for this signature in database
GPG Key ID: 137D1D75522168AB

View File

@ -171,16 +171,17 @@ func TestPreparedStmtInTransaction(t *testing.T) {
func TestPreparedStmtReset(t *testing.T) {
tx := DB.Session(&gorm.Session{PrepareStmt: true})
user := *GetUser("prepared_stmt_reset", Config{})
tx = tx.Create(&user)
pdb, ok := tx.ConnPool.(*gorm.PreparedStmtDB)
if !ok {
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()
if len(pdb.PreparedSQL) == 0 || len(pdb.Stmts) == 0 {
if len(pdb.Stmts) == 0 {
pdb.Mux.Unlock()
t.Fatalf("prepared stmt can not be empty")
}
@ -189,7 +190,7 @@ func TestPreparedStmtReset(t *testing.T) {
pdb.Reset()
pdb.Mux.Lock()
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")
}
}