Add interface for Engine & Session #23
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "unknown repository"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Author: @tamalsaha
We would like to mock Engine and Session structs in our code using https://github.com/golang/mock . To do that we need
interface
for Engine and Session. Changes required are:@lunny, does this sound acceptable?
Author: @lunny
Looks great but I don't know how to use mock to do tests.
Author: @tamalsaha
@lunny , basically you can generate a mock implementation based on the interface (or use a reflection based mock). The mock records calls and args. Unit tests can check for those. See docs here: https://godoc.org/github.com/golang/mock/gomock
One more thing that needs to be added to Session is
AutoClose()
.Author: @lunny
@tamalsaha see https://github.com/go-xorm/xorm/blob/master/interface.go