Add interface for Engine & Session #23

Closed
lunny wants to merge 1 commits from unknown repository into master
Owner

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: @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: - Add the new interfaces to core package. - Update xorm pkg's implementation to match these new interfaces. The main change required is to use use the Session interface in xorm.Engine struct. It be something like: https://github.com/go-xorm/xorm/compare/master...appscode:mock?expand=1 @lunny, does this sound acceptable?
Author
Owner

Author: @lunny

Looks great but I don't know how to use mock to do tests.

Author: @lunny Looks great but I don't know how to use mock to do tests.
Author
Owner

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: @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
Owner
Author: @lunny @tamalsaha see https://github.com/go-xorm/xorm/blob/master/interface.go
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/core#23
No description provided.