1kasa commented on code in PR #828:
URL: 
https://github.com/apache/incubator-seata-go/pull/828#discussion_r2186697336


##########
pkg/datasource/sql/undo/executor/executor.go:
##########
@@ -98,7 +99,7 @@ func (b *BaseExecutor) dataValidationAndGoOn(ctx 
context.Context, conn *sql.Conn
                        newRowJson, _ := json.Marshal(currentImage.Rows)
                        log.Infof("check dirty data failed, old and new data 
are not equal, "+
                                "tableName:[%s], oldRows:[%s],newRows:[%s].", 
afterImage.TableName, oldRowJson, newRowJson)
-                       return false, fmt.Errorf("Has dirty records when undo.")
+                       return false, serr.New(serr.SQLUndoDirtyError, "has 
dirty records when undo", nil)

Review Comment:
   Here I explain why I chose to rewrite the unit test, but because I 
encountered difficulties with the mock method queryCurrentRecords, I wanted to 
simulate this behavior in a simple way, such as through gomonkey.ApplyMethod 
patch (essentially implemented by reflect and runtime symbol table). 
queryCurrentRecords is a lowercase method, and Go's lowercase methods are not 
exported. Reflect cannot access non-exported methods, but the symbols of the 
method are implemented by decoupling into an interface (because it is 
consistent with the principle of modifying the source code as little as 
possible with unit testing), so I chose to directly implement 
testableBaseExecutor and rewrite it, although it does not look elegant.



-- 
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