-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgmock.go
70 lines (53 loc) · 2.12 KB
/
gmock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gmock
import (
"github.com/sjqzhang/gmock/mockdb"
"github.com/sjqzhang/gmock/mockgrpc"
"github.com/sjqzhang/gmock/mockhttp"
"github.com/sjqzhang/gmock/mockredis"
"github.com/sjqzhang/gmock/util"
"github.com/sjqzhang/requests"
"net/http"
"net/http/httptest"
)
func NewMockHttpServer(httpServerPort int, mockJSONDir string, allowProxyHosts []string) *mockhttp.MockHttpServer {
return mockhttp.NewMockHttpServer(httpServerPort, mockJSONDir, allowProxyHosts)
}
func NewMockGORM(pathToSqlFileName string, dbName string) *mockdb.MockGORM {
return mockdb.NewMockGORM(pathToSqlFileName, dbName)
}
func NewMockGRPC(opts ...mockgrpc.OptionGRPC) *mockgrpc.MockGRPC {
return mockgrpc.NewMockGRPC(opts...)
}
func NewMockGORMV2(pathToSqlFileName string, dbName string) *mockdb.MockGORMV2 {
return mockdb.NewMockGORMV2(pathToSqlFileName, dbName)
}
func NewMockRedisServer(port int) *mockredis.MockRedisServer {
return mockredis.NewMockRedisServer(port)
}
func NewMockXORM(pathToSqlFileName string, resetHandler func(orm *mockdb.MockXORM)) *mockdb.MockXORM {
return mockdb.NewMockXORM(pathToSqlFileName, resetHandler)
}
func NewGORMFromDSN(pathToSqlFileName string, dbType string, dsn string) *mockdb.MockGORM {
return mockdb.NewGORMFromDSN(pathToSqlFileName, dbType, dsn)
}
func NewGORMV2FromDSN(pathToSqlFileName string, dbType string, dsn string) *mockdb.MockGORMV2 {
return mockdb.NewGORMV2FromDSN(pathToSqlFileName, dbType, dsn)
}
func NewXORMFromDSN(pathToSqlFileName string, dbType string, dsn string) *mockdb.MockXORM {
return mockdb.NewXORMFromDSN(pathToSqlFileName, dbType, dsn)
}
func NewDBUtil() *util.DBUtil {
return util.NewDBUtil()
}
func Get(origurl string, args ...interface{}) (resp *requests.Response, err error) {
return requests.Get(origurl, args...)
}
func Post(origurl string, args ...interface{}) (resp *requests.Response, err error) {
return requests.Post(origurl, args...)
}
func NewRecorder() *httptest.ResponseRecorder {
return requests.NewRecorder()
}
func NewRequestForTest(method, origurl string, args ...interface{}) (*http.Request, error) {
return requests.NewRequestForTest(method, origurl, args...)
}