AlexStocks commented on code in PR #1085:
URL: 
https://github.com/apache/incubator-seata-go/pull/1085#discussion_r3004322783


##########
pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler_test.go:
##########
@@ -1041,3 +1041,92 @@ func TestConstants(t *testing.T) {
        assert.Equal(t, 24*time.Hour, cleanExpired)
        assert.Equal(t, 5*time.Minute, cleanInterval)
 }
+
+func TestDrainCacheTask(t *testing.T) {
+       log.Init()
+
+       oldInterval := cleanInterval
+       cleanInterval = 20 * time.Millisecond
+       defer func() { cleanInterval = oldInterval }()
+
+       db, mock, err := sqlmock.New()
+       assert.NoError(t, err)
+       defer db.Close()
+
+       // drainCacheTask should execute one delete batch with Begin + Commit.

Review Comment:
   [P1] 新增测试只覆盖了成功删除和 db == nil,但没有锁住最关键的失败路径。当前实现会在真正 delete 之前先把 identity 从 
logCache 移走,所以只要 Begin 或 DAO 删除返回错误,就会静默丢失这批清理任务;没有这个回归用例,后面很难发现。建议补一个 DAO 
返回错误的测试,断言失败后缓存项仍然保留或会被重新入队。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to