You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "LucienShen-Liu (via GitHub)" <gi...@apache.org> on 2025/11/03 12:46:36 UTC

[PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

LucienShen-Liu opened a new pull request, #971:
URL: https://github.com/apache/incubator-seata-go/pull/971

   <!--  Thanks for sending a pull request! 
   -->
   
   **What this PR does**:improve test coverage for pkg/datasource/sql/undo
   
   **Which issue(s) this PR fixes**:  https://github.com/apache/incubator-seata-go/issues/940
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   Fixes #
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   ```release-note
   
   ```


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "LucienShen-Liu (via GitHub)" <gi...@apache.org>.
LucienShen-Liu commented on code in PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#discussion_r2490955649


##########
pkg/datasource/sql/undo/undo_test.go:
##########
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package undo
+
+import (
+	"context"
+	"database/sql"
+	"database/sql/driver"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/mock"
+
+	"seata.apache.org/seata-go/pkg/datasource/sql/types"
+)
+
+type mockUndoLogManager struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogManager) Init() {
+	m.Called()
+}
+
+func (m *mockUndoLogManager) DeleteUndoLog(ctx context.Context, xid string, branchID int64, conn *sql.Conn) error {
+	args := m.Called(ctx, xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) BatchDeleteUndoLog(xid []string, branchID []int64, conn *sql.Conn) error {
+	args := m.Called(xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, conn driver.Conn) error {
+	args := m.Called(tranCtx, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) RunUndo(ctx context.Context, xid string, branchID int64, conn *sql.DB, dbName string) error {
+	args := m.Called(ctx, xid, branchID, conn, dbName)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) DBType() types.DBType {
+	args := m.Called()
+	return args.Get(0).(types.DBType)
+}
+
+func (m *mockUndoLogManager) HasUndoLogTable(ctx context.Context, conn *sql.Conn) (bool, error) {
+	args := m.Called(ctx, conn)
+	return args.Bool(0), args.Error(1)
+}
+
+type mockUndoLogBuilder struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogBuilder) BeforeImage(ctx context.Context, execCtx *types.ExecContext) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) AfterImage(ctx context.Context, execCtx *types.ExecContext, beforeImages []*types.RecordImage) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx, beforeImages)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) GetExecutorType() types.ExecutorType {
+	args := m.Called()
+	return args.Get(0).(types.ExecutorType)
+}
+
+func TestRegisterUndoLogManager(t *testing.T) {
+	tests := []struct {
+		name    string
+		manager UndoLogManager
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "register mysql manager",
+			manager: &mockUndoLogManager{},
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			mockMgr := tt.manager.(*mockUndoLogManager)
+			mockMgr.On("DBType").Return(tt.dbType)
+			mockMgr.On("Init").Return()
+
+			err := RegisterUndoLogManager(tt.manager)
+			if tt.wantErr {
+				assert.Error(t, err)
+			} else {
+				assert.NoError(t, err)
+			}
+
+			err = RegisterUndoLogManager(tt.manager)
+			assert.NoError(t, err)
+		})
+	}
+}
+
+func TestRegisterUndoLogBuilder(t *testing.T) {
+	executorType := types.InsertExecutor
+	builderFunc := func() UndoLogBuilder {
+		return &mockUndoLogBuilder{}
+	}
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+
+	builder := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder)
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+	builder2 := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder2)
+}
+
+func TestGetUndologBuilder(t *testing.T) {
+	tests := []struct {
+		name         string
+		executorType types.ExecutorType
+		setup        func()
+		want         bool
+	}{
+		{
+			name:         "get existing builder",
+			executorType: types.UpdateExecutor,
+			setup: func() {
+				RegisterUndoLogBuilder(types.UpdateExecutor, func() UndoLogBuilder {
+					return &mockUndoLogBuilder{}
+				})
+			},
+			want: true,
+		},
+		{
+			name:         "get non-existing builder",
+			executorType: types.DeleteExecutor,
+			setup:        func() {},
+			want:         false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			tt.setup()
+			builder := GetUndologBuilder(tt.executorType)
+			if tt.want {
+				assert.NotNil(t, builder)
+			} else {
+				assert.Nil(t, builder)
+			}
+		})
+	}
+}
+
+func TestGetUndoLogManager(t *testing.T) {
+	mockMgr := &mockUndoLogManager{}
+	mockMgr.On("DBType").Return(types.DBTypeMySQL)
+	mockMgr.On("Init").Return()
+
+	err := RegisterUndoLogManager(mockMgr)
+	assert.NoError(t, err)
+
+	tests := []struct {
+		name    string
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "get existing manager",
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+		{
+			name:    "get non-existing manager",
+			dbType:  types.DBTypePostgreSQL,
+			wantErr: true,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			manager, err := GetUndoLogManager(tt.dbType)
+			if tt.wantErr {
+				assert.Error(t, err)
+				assert.Nil(t, manager)
+				assert.Contains(t, err.Error(), "not found UndoLogManager")
+			} else {
+				assert.NoError(t, err)
+				assert.NotNil(t, manager)
+			}
+		})
+	}
+}
+
+func TestUndologRecord_CanUndo(t *testing.T) {
+	tests := []struct {
+		name      string
+		logStatus UndoLogStatue
+		want      bool
+	}{
+		{
+			name:      "can undo - normal status",
+			logStatus: UndoLogStatueNormnal,
+			want:      true,
+		},
+		{
+			name:      "cannot undo - global finished",
+			logStatus: UndoLogStatueGlobalFinished,

Review Comment:
   The issue was a spelling error in the original constant name; it has now been corrected.



-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "LucienShen-Liu (via GitHub)" <gi...@apache.org>.
LucienShen-Liu commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3551594312

   > > > Hi, @LucienShen-Liu I noticed that the test coverage has slightly decreased by **0.43%** in this PR.
   > > 
   > > 
   > > OMG, thanks for the comment, I'll add it later.
   > 
   > I noticed that the test coverage for the latest commit is still negative. Please review the changes and ensure they are properly covered by unit tests.
   
   
   
   > > > 你好,@LucienShen-Liu我注意到此 PR 中的测试覆盖率略微下降了**0.43% 。**
   > > 
   > > 
   > > 我的天哪,谢谢你的评论,我稍后会添加。
   > 
   > 我注意到最新提交的测试覆盖率仍然为负值。请检查这些更改,并确保它们都已被单元测试完全覆盖。
   
   done


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#discussion_r2487086626


##########
pkg/datasource/sql/undo/undo_test.go:
##########
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package undo
+
+import (
+	"context"
+	"database/sql"
+	"database/sql/driver"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/mock"
+
+	"seata.apache.org/seata-go/pkg/datasource/sql/types"
+)
+
+type mockUndoLogManager struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogManager) Init() {
+	m.Called()
+}
+
+func (m *mockUndoLogManager) DeleteUndoLog(ctx context.Context, xid string, branchID int64, conn *sql.Conn) error {
+	args := m.Called(ctx, xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) BatchDeleteUndoLog(xid []string, branchID []int64, conn *sql.Conn) error {
+	args := m.Called(xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, conn driver.Conn) error {
+	args := m.Called(tranCtx, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) RunUndo(ctx context.Context, xid string, branchID int64, conn *sql.DB, dbName string) error {
+	args := m.Called(ctx, xid, branchID, conn, dbName)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) DBType() types.DBType {
+	args := m.Called()
+	return args.Get(0).(types.DBType)
+}
+
+func (m *mockUndoLogManager) HasUndoLogTable(ctx context.Context, conn *sql.Conn) (bool, error) {
+	args := m.Called(ctx, conn)
+	return args.Bool(0), args.Error(1)
+}
+
+type mockUndoLogBuilder struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogBuilder) BeforeImage(ctx context.Context, execCtx *types.ExecContext) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) AfterImage(ctx context.Context, execCtx *types.ExecContext, beforeImages []*types.RecordImage) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx, beforeImages)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) GetExecutorType() types.ExecutorType {
+	args := m.Called()
+	return args.Get(0).(types.ExecutorType)
+}
+
+func TestRegisterUndoLogManager(t *testing.T) {
+	tests := []struct {
+		name    string
+		manager UndoLogManager
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "register mysql manager",
+			manager: &mockUndoLogManager{},
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			mockMgr := tt.manager.(*mockUndoLogManager)
+			mockMgr.On("DBType").Return(tt.dbType)
+			mockMgr.On("Init").Return()
+
+			err := RegisterUndoLogManager(tt.manager)
+			if tt.wantErr {
+				assert.Error(t, err)
+			} else {
+				assert.NoError(t, err)
+			}
+
+			err = RegisterUndoLogManager(tt.manager)
+			assert.NoError(t, err)
+		})
+	}
+}
+
+func TestRegisterUndoLogBuilder(t *testing.T) {
+	executorType := types.InsertExecutor
+	builderFunc := func() UndoLogBuilder {
+		return &mockUndoLogBuilder{}
+	}
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+
+	builder := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder)
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+	builder2 := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder2)
+}
+
+func TestGetUndologBuilder(t *testing.T) {
+	tests := []struct {
+		name         string
+		executorType types.ExecutorType
+		setup        func()
+		want         bool
+	}{
+		{
+			name:         "get existing builder",
+			executorType: types.UpdateExecutor,
+			setup: func() {
+				RegisterUndoLogBuilder(types.UpdateExecutor, func() UndoLogBuilder {
+					return &mockUndoLogBuilder{}
+				})
+			},
+			want: true,
+		},
+		{
+			name:         "get non-existing builder",
+			executorType: types.DeleteExecutor,
+			setup:        func() {},
+			want:         false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			tt.setup()
+			builder := GetUndologBuilder(tt.executorType)
+			if tt.want {
+				assert.NotNil(t, builder)
+			} else {
+				assert.Nil(t, builder)
+			}
+		})
+	}
+}
+
+func TestGetUndoLogManager(t *testing.T) {
+	mockMgr := &mockUndoLogManager{}
+	mockMgr.On("DBType").Return(types.DBTypeMySQL)
+	mockMgr.On("Init").Return()
+
+	err := RegisterUndoLogManager(mockMgr)
+	assert.NoError(t, err)
+
+	tests := []struct {
+		name    string
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "get existing manager",
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+		{
+			name:    "get non-existing manager",
+			dbType:  types.DBTypePostgreSQL,
+			wantErr: true,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			manager, err := GetUndoLogManager(tt.dbType)
+			if tt.wantErr {
+				assert.Error(t, err)
+				assert.Nil(t, manager)
+				assert.Contains(t, err.Error(), "not found UndoLogManager")
+			} else {
+				assert.NoError(t, err)
+				assert.NotNil(t, manager)
+			}
+		})
+	}
+}
+
+func TestUndologRecord_CanUndo(t *testing.T) {
+	tests := []struct {
+		name      string
+		logStatus UndoLogStatue
+		want      bool
+	}{
+		{
+			name:      "can undo - normal status",
+			logStatus: UndoLogStatueNormnal,
+			want:      true,
+		},
+		{
+			name:      "cannot undo - global finished",
+			logStatus: UndoLogStatueGlobalFinished,

Review Comment:
   Corrected spelling of 'UndoLogStatue' to 'UndoLogStatus'. The type name contains typo 'Statue' instead of 'Status'.
   ```suggestion
   		logStatus UndoLogStatus
   		want      bool
   	}{
   		{
   			name:      "can undo - normal status",
   			logStatus: UndoLogStatusNormal,
   			want:      true,
   		},
   		{
   			name:      "cannot undo - global finished",
   			logStatus: UndoLogStatusGlobalFinished,
   ```



##########
pkg/datasource/sql/undo/undo_test.go:
##########
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package undo
+
+import (
+	"context"
+	"database/sql"
+	"database/sql/driver"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/mock"
+
+	"seata.apache.org/seata-go/pkg/datasource/sql/types"
+)
+
+type mockUndoLogManager struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogManager) Init() {
+	m.Called()
+}
+
+func (m *mockUndoLogManager) DeleteUndoLog(ctx context.Context, xid string, branchID int64, conn *sql.Conn) error {
+	args := m.Called(ctx, xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) BatchDeleteUndoLog(xid []string, branchID []int64, conn *sql.Conn) error {
+	args := m.Called(xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, conn driver.Conn) error {
+	args := m.Called(tranCtx, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) RunUndo(ctx context.Context, xid string, branchID int64, conn *sql.DB, dbName string) error {
+	args := m.Called(ctx, xid, branchID, conn, dbName)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) DBType() types.DBType {
+	args := m.Called()
+	return args.Get(0).(types.DBType)
+}
+
+func (m *mockUndoLogManager) HasUndoLogTable(ctx context.Context, conn *sql.Conn) (bool, error) {
+	args := m.Called(ctx, conn)
+	return args.Bool(0), args.Error(1)
+}
+
+type mockUndoLogBuilder struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogBuilder) BeforeImage(ctx context.Context, execCtx *types.ExecContext) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) AfterImage(ctx context.Context, execCtx *types.ExecContext, beforeImages []*types.RecordImage) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx, beforeImages)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) GetExecutorType() types.ExecutorType {
+	args := m.Called()
+	return args.Get(0).(types.ExecutorType)
+}
+
+func TestRegisterUndoLogManager(t *testing.T) {
+	tests := []struct {
+		name    string
+		manager UndoLogManager
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "register mysql manager",
+			manager: &mockUndoLogManager{},
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			mockMgr := tt.manager.(*mockUndoLogManager)
+			mockMgr.On("DBType").Return(tt.dbType)
+			mockMgr.On("Init").Return()
+
+			err := RegisterUndoLogManager(tt.manager)
+			if tt.wantErr {
+				assert.Error(t, err)
+			} else {
+				assert.NoError(t, err)
+			}
+
+			err = RegisterUndoLogManager(tt.manager)
+			assert.NoError(t, err)
+		})
+	}
+}
+
+func TestRegisterUndoLogBuilder(t *testing.T) {
+	executorType := types.InsertExecutor
+	builderFunc := func() UndoLogBuilder {
+		return &mockUndoLogBuilder{}
+	}
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+
+	builder := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder)
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+	builder2 := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder2)
+}
+
+func TestGetUndologBuilder(t *testing.T) {
+	tests := []struct {
+		name         string
+		executorType types.ExecutorType
+		setup        func()
+		want         bool
+	}{
+		{
+			name:         "get existing builder",
+			executorType: types.UpdateExecutor,
+			setup: func() {
+				RegisterUndoLogBuilder(types.UpdateExecutor, func() UndoLogBuilder {
+					return &mockUndoLogBuilder{}
+				})
+			},
+			want: true,
+		},
+		{
+			name:         "get non-existing builder",
+			executorType: types.DeleteExecutor,
+			setup:        func() {},
+			want:         false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			tt.setup()
+			builder := GetUndologBuilder(tt.executorType)
+			if tt.want {
+				assert.NotNil(t, builder)
+			} else {
+				assert.Nil(t, builder)
+			}
+		})
+	}
+}
+
+func TestGetUndoLogManager(t *testing.T) {
+	mockMgr := &mockUndoLogManager{}
+	mockMgr.On("DBType").Return(types.DBTypeMySQL)
+	mockMgr.On("Init").Return()
+
+	err := RegisterUndoLogManager(mockMgr)
+	assert.NoError(t, err)
+
+	tests := []struct {
+		name    string
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "get existing manager",
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+		{
+			name:    "get non-existing manager",
+			dbType:  types.DBTypePostgreSQL,
+			wantErr: true,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			manager, err := GetUndoLogManager(tt.dbType)
+			if tt.wantErr {
+				assert.Error(t, err)
+				assert.Nil(t, manager)
+				assert.Contains(t, err.Error(), "not found UndoLogManager")
+			} else {
+				assert.NoError(t, err)
+				assert.NotNil(t, manager)
+			}
+		})
+	}
+}
+
+func TestUndologRecord_CanUndo(t *testing.T) {
+	tests := []struct {
+		name      string
+		logStatus UndoLogStatue
+		want      bool
+	}{
+		{
+			name:      "can undo - normal status",
+			logStatus: UndoLogStatueNormnal,

Review Comment:
   Corrected spelling of 'UndoLogStatueNormnal' to 'UndoLogStatusNormal'. The constant name contains typo 'Statue' instead of 'Status' and 'Normnal' instead of 'Normal'.
   ```suggestion
   			logStatus: UndoLogStatusNormal,
   ```



##########
pkg/datasource/sql/undo/undo_test.go:
##########
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package undo
+
+import (
+	"context"
+	"database/sql"
+	"database/sql/driver"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/mock"
+
+	"seata.apache.org/seata-go/pkg/datasource/sql/types"
+)
+
+type mockUndoLogManager struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogManager) Init() {
+	m.Called()
+}
+
+func (m *mockUndoLogManager) DeleteUndoLog(ctx context.Context, xid string, branchID int64, conn *sql.Conn) error {
+	args := m.Called(ctx, xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) BatchDeleteUndoLog(xid []string, branchID []int64, conn *sql.Conn) error {
+	args := m.Called(xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, conn driver.Conn) error {
+	args := m.Called(tranCtx, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) RunUndo(ctx context.Context, xid string, branchID int64, conn *sql.DB, dbName string) error {
+	args := m.Called(ctx, xid, branchID, conn, dbName)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) DBType() types.DBType {
+	args := m.Called()
+	return args.Get(0).(types.DBType)
+}
+
+func (m *mockUndoLogManager) HasUndoLogTable(ctx context.Context, conn *sql.Conn) (bool, error) {
+	args := m.Called(ctx, conn)
+	return args.Bool(0), args.Error(1)
+}
+
+type mockUndoLogBuilder struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogBuilder) BeforeImage(ctx context.Context, execCtx *types.ExecContext) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) AfterImage(ctx context.Context, execCtx *types.ExecContext, beforeImages []*types.RecordImage) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx, beforeImages)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) GetExecutorType() types.ExecutorType {
+	args := m.Called()
+	return args.Get(0).(types.ExecutorType)
+}
+
+func TestRegisterUndoLogManager(t *testing.T) {
+	tests := []struct {
+		name    string
+		manager UndoLogManager
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "register mysql manager",
+			manager: &mockUndoLogManager{},
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			mockMgr := tt.manager.(*mockUndoLogManager)
+			mockMgr.On("DBType").Return(tt.dbType)
+			mockMgr.On("Init").Return()
+
+			err := RegisterUndoLogManager(tt.manager)
+			if tt.wantErr {
+				assert.Error(t, err)
+			} else {
+				assert.NoError(t, err)
+			}
+
+			err = RegisterUndoLogManager(tt.manager)
+			assert.NoError(t, err)
+		})
+	}
+}
+
+func TestRegisterUndoLogBuilder(t *testing.T) {
+	executorType := types.InsertExecutor
+	builderFunc := func() UndoLogBuilder {
+		return &mockUndoLogBuilder{}
+	}
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+
+	builder := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder)
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+	builder2 := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder2)
+}
+
+func TestGetUndologBuilder(t *testing.T) {
+	tests := []struct {
+		name         string
+		executorType types.ExecutorType
+		setup        func()
+		want         bool
+	}{
+		{
+			name:         "get existing builder",
+			executorType: types.UpdateExecutor,
+			setup: func() {
+				RegisterUndoLogBuilder(types.UpdateExecutor, func() UndoLogBuilder {
+					return &mockUndoLogBuilder{}
+				})
+			},
+			want: true,
+		},
+		{
+			name:         "get non-existing builder",
+			executorType: types.DeleteExecutor,
+			setup:        func() {},
+			want:         false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			tt.setup()
+			builder := GetUndologBuilder(tt.executorType)
+			if tt.want {
+				assert.NotNil(t, builder)
+			} else {
+				assert.Nil(t, builder)
+			}
+		})
+	}
+}
+
+func TestGetUndoLogManager(t *testing.T) {
+	mockMgr := &mockUndoLogManager{}
+	mockMgr.On("DBType").Return(types.DBTypeMySQL)
+	mockMgr.On("Init").Return()
+
+	err := RegisterUndoLogManager(mockMgr)
+	assert.NoError(t, err)
+
+	tests := []struct {
+		name    string
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "get existing manager",
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+		{
+			name:    "get non-existing manager",
+			dbType:  types.DBTypePostgreSQL,
+			wantErr: true,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			manager, err := GetUndoLogManager(tt.dbType)
+			if tt.wantErr {
+				assert.Error(t, err)
+				assert.Nil(t, manager)
+				assert.Contains(t, err.Error(), "not found UndoLogManager")
+			} else {
+				assert.NoError(t, err)
+				assert.NotNil(t, manager)
+			}
+		})
+	}
+}
+
+func TestUndologRecord_CanUndo(t *testing.T) {
+	tests := []struct {
+		name      string
+		logStatus UndoLogStatue
+		want      bool
+	}{
+		{
+			name:      "can undo - normal status",
+			logStatus: UndoLogStatueNormnal,
+			want:      true,
+		},
+		{
+			name:      "cannot undo - global finished",
+			logStatus: UndoLogStatueGlobalFinished,

Review Comment:
   Corrected spelling of 'UndoLogStatueGlobalFinished' to 'UndoLogStatusGlobalFinished'. The constant name contains typo 'Statue' instead of 'Status'.
   ```suggestion
   			logStatus: UndoLogStatusGlobalFinished,
   ```



-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "LucienShen-Liu (via GitHub)" <gi...@apache.org>.
LucienShen-Liu commented on code in PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#discussion_r2490954762


##########
pkg/datasource/sql/undo/undo_test.go:
##########
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package undo
+
+import (
+	"context"
+	"database/sql"
+	"database/sql/driver"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/mock"
+
+	"seata.apache.org/seata-go/pkg/datasource/sql/types"
+)
+
+type mockUndoLogManager struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogManager) Init() {
+	m.Called()
+}
+
+func (m *mockUndoLogManager) DeleteUndoLog(ctx context.Context, xid string, branchID int64, conn *sql.Conn) error {
+	args := m.Called(ctx, xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) BatchDeleteUndoLog(xid []string, branchID []int64, conn *sql.Conn) error {
+	args := m.Called(xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, conn driver.Conn) error {
+	args := m.Called(tranCtx, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) RunUndo(ctx context.Context, xid string, branchID int64, conn *sql.DB, dbName string) error {
+	args := m.Called(ctx, xid, branchID, conn, dbName)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) DBType() types.DBType {
+	args := m.Called()
+	return args.Get(0).(types.DBType)
+}
+
+func (m *mockUndoLogManager) HasUndoLogTable(ctx context.Context, conn *sql.Conn) (bool, error) {
+	args := m.Called(ctx, conn)
+	return args.Bool(0), args.Error(1)
+}
+
+type mockUndoLogBuilder struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogBuilder) BeforeImage(ctx context.Context, execCtx *types.ExecContext) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) AfterImage(ctx context.Context, execCtx *types.ExecContext, beforeImages []*types.RecordImage) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx, beforeImages)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) GetExecutorType() types.ExecutorType {
+	args := m.Called()
+	return args.Get(0).(types.ExecutorType)
+}
+
+func TestRegisterUndoLogManager(t *testing.T) {
+	tests := []struct {
+		name    string
+		manager UndoLogManager
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "register mysql manager",
+			manager: &mockUndoLogManager{},
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			mockMgr := tt.manager.(*mockUndoLogManager)
+			mockMgr.On("DBType").Return(tt.dbType)
+			mockMgr.On("Init").Return()
+
+			err := RegisterUndoLogManager(tt.manager)
+			if tt.wantErr {
+				assert.Error(t, err)
+			} else {
+				assert.NoError(t, err)
+			}
+
+			err = RegisterUndoLogManager(tt.manager)
+			assert.NoError(t, err)
+		})
+	}
+}
+
+func TestRegisterUndoLogBuilder(t *testing.T) {
+	executorType := types.InsertExecutor
+	builderFunc := func() UndoLogBuilder {
+		return &mockUndoLogBuilder{}
+	}
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+
+	builder := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder)
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+	builder2 := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder2)
+}
+
+func TestGetUndologBuilder(t *testing.T) {
+	tests := []struct {
+		name         string
+		executorType types.ExecutorType
+		setup        func()
+		want         bool
+	}{
+		{
+			name:         "get existing builder",
+			executorType: types.UpdateExecutor,
+			setup: func() {
+				RegisterUndoLogBuilder(types.UpdateExecutor, func() UndoLogBuilder {
+					return &mockUndoLogBuilder{}
+				})
+			},
+			want: true,
+		},
+		{
+			name:         "get non-existing builder",
+			executorType: types.DeleteExecutor,
+			setup:        func() {},
+			want:         false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			tt.setup()
+			builder := GetUndologBuilder(tt.executorType)
+			if tt.want {
+				assert.NotNil(t, builder)
+			} else {
+				assert.Nil(t, builder)
+			}
+		})
+	}
+}
+
+func TestGetUndoLogManager(t *testing.T) {
+	mockMgr := &mockUndoLogManager{}
+	mockMgr.On("DBType").Return(types.DBTypeMySQL)
+	mockMgr.On("Init").Return()
+
+	err := RegisterUndoLogManager(mockMgr)
+	assert.NoError(t, err)
+
+	tests := []struct {
+		name    string
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "get existing manager",
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+		{
+			name:    "get non-existing manager",
+			dbType:  types.DBTypePostgreSQL,
+			wantErr: true,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			manager, err := GetUndoLogManager(tt.dbType)
+			if tt.wantErr {
+				assert.Error(t, err)
+				assert.Nil(t, manager)
+				assert.Contains(t, err.Error(), "not found UndoLogManager")
+			} else {
+				assert.NoError(t, err)
+				assert.NotNil(t, manager)
+			}
+		})
+	}
+}
+
+func TestUndologRecord_CanUndo(t *testing.T) {
+	tests := []struct {
+		name      string
+		logStatus UndoLogStatue
+		want      bool
+	}{
+		{
+			name:      "can undo - normal status",
+			logStatus: UndoLogStatueNormnal,

Review Comment:
   The issue was a spelling error in the original constant name; it has now been corrected.



##########
pkg/datasource/sql/undo/undo_test.go:
##########
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package undo
+
+import (
+	"context"
+	"database/sql"
+	"database/sql/driver"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/mock"
+
+	"seata.apache.org/seata-go/pkg/datasource/sql/types"
+)
+
+type mockUndoLogManager struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogManager) Init() {
+	m.Called()
+}
+
+func (m *mockUndoLogManager) DeleteUndoLog(ctx context.Context, xid string, branchID int64, conn *sql.Conn) error {
+	args := m.Called(ctx, xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) BatchDeleteUndoLog(xid []string, branchID []int64, conn *sql.Conn) error {
+	args := m.Called(xid, branchID, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, conn driver.Conn) error {
+	args := m.Called(tranCtx, conn)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) RunUndo(ctx context.Context, xid string, branchID int64, conn *sql.DB, dbName string) error {
+	args := m.Called(ctx, xid, branchID, conn, dbName)
+	return args.Error(0)
+}
+
+func (m *mockUndoLogManager) DBType() types.DBType {
+	args := m.Called()
+	return args.Get(0).(types.DBType)
+}
+
+func (m *mockUndoLogManager) HasUndoLogTable(ctx context.Context, conn *sql.Conn) (bool, error) {
+	args := m.Called(ctx, conn)
+	return args.Bool(0), args.Error(1)
+}
+
+type mockUndoLogBuilder struct {
+	mock.Mock
+}
+
+func (m *mockUndoLogBuilder) BeforeImage(ctx context.Context, execCtx *types.ExecContext) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) AfterImage(ctx context.Context, execCtx *types.ExecContext, beforeImages []*types.RecordImage) ([]*types.RecordImage, error) {
+	args := m.Called(ctx, execCtx, beforeImages)
+	return args.Get(0).([]*types.RecordImage), args.Error(1)
+}
+
+func (m *mockUndoLogBuilder) GetExecutorType() types.ExecutorType {
+	args := m.Called()
+	return args.Get(0).(types.ExecutorType)
+}
+
+func TestRegisterUndoLogManager(t *testing.T) {
+	tests := []struct {
+		name    string
+		manager UndoLogManager
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "register mysql manager",
+			manager: &mockUndoLogManager{},
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			mockMgr := tt.manager.(*mockUndoLogManager)
+			mockMgr.On("DBType").Return(tt.dbType)
+			mockMgr.On("Init").Return()
+
+			err := RegisterUndoLogManager(tt.manager)
+			if tt.wantErr {
+				assert.Error(t, err)
+			} else {
+				assert.NoError(t, err)
+			}
+
+			err = RegisterUndoLogManager(tt.manager)
+			assert.NoError(t, err)
+		})
+	}
+}
+
+func TestRegisterUndoLogBuilder(t *testing.T) {
+	executorType := types.InsertExecutor
+	builderFunc := func() UndoLogBuilder {
+		return &mockUndoLogBuilder{}
+	}
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+
+	builder := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder)
+
+	RegisterUndoLogBuilder(executorType, builderFunc)
+	builder2 := GetUndologBuilder(executorType)
+	assert.NotNil(t, builder2)
+}
+
+func TestGetUndologBuilder(t *testing.T) {
+	tests := []struct {
+		name         string
+		executorType types.ExecutorType
+		setup        func()
+		want         bool
+	}{
+		{
+			name:         "get existing builder",
+			executorType: types.UpdateExecutor,
+			setup: func() {
+				RegisterUndoLogBuilder(types.UpdateExecutor, func() UndoLogBuilder {
+					return &mockUndoLogBuilder{}
+				})
+			},
+			want: true,
+		},
+		{
+			name:         "get non-existing builder",
+			executorType: types.DeleteExecutor,
+			setup:        func() {},
+			want:         false,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			tt.setup()
+			builder := GetUndologBuilder(tt.executorType)
+			if tt.want {
+				assert.NotNil(t, builder)
+			} else {
+				assert.Nil(t, builder)
+			}
+		})
+	}
+}
+
+func TestGetUndoLogManager(t *testing.T) {
+	mockMgr := &mockUndoLogManager{}
+	mockMgr.On("DBType").Return(types.DBTypeMySQL)
+	mockMgr.On("Init").Return()
+
+	err := RegisterUndoLogManager(mockMgr)
+	assert.NoError(t, err)
+
+	tests := []struct {
+		name    string
+		dbType  types.DBType
+		wantErr bool
+	}{
+		{
+			name:    "get existing manager",
+			dbType:  types.DBTypeMySQL,
+			wantErr: false,
+		},
+		{
+			name:    "get non-existing manager",
+			dbType:  types.DBTypePostgreSQL,
+			wantErr: true,
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			manager, err := GetUndoLogManager(tt.dbType)
+			if tt.wantErr {
+				assert.Error(t, err)
+				assert.Nil(t, manager)
+				assert.Contains(t, err.Error(), "not found UndoLogManager")
+			} else {
+				assert.NoError(t, err)
+				assert.NotNil(t, manager)
+			}
+		})
+	}
+}
+
+func TestUndologRecord_CanUndo(t *testing.T) {
+	tests := []struct {
+		name      string
+		logStatus UndoLogStatue
+		want      bool
+	}{
+		{
+			name:      "can undo - normal status",
+			logStatus: UndoLogStatueNormnal,
+			want:      true,
+		},
+		{
+			name:      "cannot undo - global finished",
+			logStatus: UndoLogStatueGlobalFinished,

Review Comment:
   The issue was a spelling error in the original constant name; it has now been corrected.



-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "Code-Fight (via GitHub)" <gi...@apache.org>.
Code-Fight commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3489285704

   @LucienShen-Liu pls resolve conflicts


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3489006982

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata-go/pull/971?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `25.00000%` with `3 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 39.95%. Comparing base ([`a1c3764`](https://app.codecov.io/gh/apache/incubator-seata-go/commit/a1c37641f95f42572c4a300c83f6ca64d4e269c9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d36aa82`](https://app.codecov.io/gh/apache/incubator-seata-go/commit/d36aa8287f43c2645903cc224e078c1874e9cf7e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata-go/pull/971?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [pkg/datasource/sql/undo/base/undo.go](https://app.codecov.io/gh/apache/incubator-seata-go/pull/971?src=pr&el=tree&filepath=pkg%2Fdatasource%2Fsql%2Fundo%2Fbase%2Fundo.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGtnL2RhdGFzb3VyY2Uvc3FsL3VuZG8vYmFzZS91bmRvLmdv) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata-go/pull/971?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #971      +/-   ##
   ==========================================
   + Coverage   38.17%   39.95%   +1.77%     
   ==========================================
     Files         188      197       +9     
     Lines       11417    12188     +771     
   ==========================================
   + Hits         4359     4870     +511     
   - Misses       6628     6885     +257     
   - Partials      430      433       +3     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/incubator-seata-go/pull/971?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "FinnTew (via GitHub)" <gi...@apache.org>.
FinnTew commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3506386982

   Plz resolve conflicts.


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "LucienShen-Liu (via GitHub)" <gi...@apache.org>.
LucienShen-Liu commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3496571340

   > Hi, @LucienShen-Liu I noticed that the test coverage has slightly decreased by **0.43%** in this PR.
   
   OMG, thanks for the comment, I'll add it later.


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "WangzJi (via GitHub)" <gi...@apache.org>.
WangzJi commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3550478814

   > > Hi, @LucienShen-Liu I noticed that the test coverage has slightly decreased by **0.43%** in this PR.
   > 
   > OMG, thanks for the comment, I'll add it later.
   
   I noticed that the test coverage for the latest commit is still negative. Please review the changes and ensure they are properly covered by unit tests.


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "LucienShen-Liu (via GitHub)" <gi...@apache.org>.
LucienShen-Liu commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3489681560

   > @LucienShen-Liu pls resolve conflicts
   
   done
   


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "WangzJi (via GitHub)" <gi...@apache.org>.
WangzJi commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3496298865

   Hi, @LucienShen-Liu 
   I noticed that the test coverage has slightly decreased by **0.43%** in this PR.


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "Code-Fight (via GitHub)" <gi...@apache.org>.
Code-Fight merged PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] test: improve test coverage for pkg/datasource/sql/undo [incubator-seata-go]

Posted by "Code-Fight (via GitHub)" <gi...@apache.org>.
Code-Fight commented on PR #971:
URL: https://github.com/apache/incubator-seata-go/pull/971#issuecomment-3536434364

   @LucienShen-Liu  pls reslove conficts


-- 
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: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org