From 3ccf0b0ff7a84e76e9f2769d3c5e17537084a5f5 Mon Sep 17 00:00:00 2001 From: xiezhaodong Date: Thu, 24 Apr 2025 16:14:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E4=BD=BF=E7=94=A8lru?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/prepared_stmt_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/prepared_stmt_test.go b/tests/prepared_stmt_test.go index cb186820..c6597594 100644 --- a/tests/prepared_stmt_test.go +++ b/tests/prepared_stmt_test.go @@ -127,9 +127,14 @@ func TestPreparedStmtLruFromTransaction(t *testing.T) { if result := tx2.Where("name=?", "zzjin").Delete(&User{}); result.Error != nil || result.RowsAffected != 0 { t.Fatalf("Failed, got error: %v, rows affected: %v", result.Error, result.RowsAffected) } + tx2.Commit() - time.Sleep(time.Second * 40) conn, ok := tx.ConnPool.(*gorm.PreparedStmtDB) + lens := len(conn.Stmts.AllMap()) + if lens == 0 { + t.Fatalf("lru should not be empty") + } + time.Sleep(time.Second * 40) AssertEqual(t, ok, true) AssertEqual(t, len(conn.Stmts.AllMap()), 0) }