@@ -33,7 +33,7 @@ There are two possible ways to use `mocket`:
33
33
34
34
##### Enabling driver
35
35
36
- Somewhere in your code to set up a tests
36
+ Somewhere in your code, do this to set up a tests
37
37
38
38
``` go
39
39
import (
@@ -46,14 +46,14 @@ func SetupTests() {
46
46
mocket.Catcher .Register ()
47
47
// GORM
48
48
db , err := gorm.Open (mocket.DRIVER_NAME , " any_string" ) // Could be any connection string
49
- app.DB = db // assumption that it will be used everywhere the same
49
+ app.DB = db // Assumption that it will be used everywhere the same
50
50
// OR
51
51
// Regular sql package usage
52
52
db , err := sql.Open (mocket.DRIVER_NAME , " any_string" )
53
53
}
54
54
```
55
55
56
- Now if use singleton instance of DB, it uses everywhere mocked connection.
56
+ Now, if you use a singleton instance of DB, it will use a mocked connection everywhere .
57
57
58
58
##### Chain usage
59
59
@@ -70,7 +70,8 @@ func TestHandler(t *testing.T) {
70
70
GlobalMock := mocket.Catcher
71
71
GlobalMock.Logging = true // log mocket behavior
72
72
73
- commonReply := []map [string ]interface {}{{" id" : " 2" , " field" : " value" }}
73
+ // field names here mapped to the database schema
74
+ commonReply := []map [string ]interface {}{{" some_id" : " 2" , " field" : " value" }}
74
75
// Mock only by query pattern
75
76
GlobalMock.NewMock ().WithQuery (` "campaigns".name IS NULL AND (("uuid" = test_uuid))` ).WithReply (commonReply)
76
77
Post (recorder, request) // call handler
0 commit comments