Copilot commented on code in PR #1096:
URL:
https://github.com/apache/incubator-seata-go/pull/1096#discussion_r3045249621
##########
pkg/datasource/sql/exec/at/at_executor_test.go:
##########
@@ -358,6 +358,91 @@ func TestATExecutor_ExecWithValue_ParserError(t
*testing.T) {
assert.Nil(t, result, "result should be nil on error")
}
+func TestATExecutors_ExecContext_BeforeHookError(t *testing.T) {
+ beforeErr := fmt.Errorf("before hook error")
+
+ tests := []struct {
+ name string
+ newExecutor func(hooks []exec.SQLHook) executor
+ }{
+ {
+ name: "insert",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &insertExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "insert on update",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &insertOnUpdateExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "delete",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return deleteExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "multi delete",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &multiDeleteExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "multi",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &multiExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "multi update",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &multiUpdateExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "select for update",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &selectForUpdateExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "update",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &updateExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ {
+ name: "update join",
+ newExecutor: func(hooks []exec.SQLHook) executor {
+ return &updateJoinExecutor{baseExecutor:
baseExecutor{hooks: hooks}, execContext: &types.ExecContext{}}
+ },
+ },
+ }
+
+ for _, tt := range tests {
Review Comment:
This subtest loop captures the range variable `tt` in a closure. Since the
module targets Go 1.20 (go.mod), this will cause all subtests to use the last
test case value, reducing coverage and potentially hiding failures. Shadow `tt`
inside the loop (e.g., `tt := tt`) before calling `t.Run` to make the test
correct on Go <1.22.
```suggestion
for _, tt := range tests {
tt := tt
```
--
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]