-
Notifications
You must be signed in to change notification settings - Fork 8
/
context_mock.go
122 lines (95 loc) · 2.75 KB
/
context_mock.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package application
import (
"fmt"
"github.com/PolarPanda611/trinitygo/httputil"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"github.com/stretchr/testify/mock"
)
var _ Context = new(ContextMock)
// ContextMock mock impl for Context
type ContextMock struct {
mock.Mock
}
// NewHTTPServiceRequest Mock
func (c *ContextMock) NewHTTPServiceRequest(serviceName string, method httputil.RequestMethod, path string, body []byte) (int, interface{}, error) {
args := c.Called(serviceName, method, path, body)
return args.Int(0), args.Get(1), args.Error(2)
}
// Application application mock
func (c *ContextMock) Application() Application {
args := c.Called()
return args.Get(0).(Application)
}
// AutoFreeOn set auto free on
func (c *ContextMock) AutoFreeOn() {
}
// AutoFreeOff set auto free off
func (c *ContextMock) AutoFreeOff() {
}
func (c *ContextMock) AutoFree() bool {
args := c.Called()
return args.Bool(0)
}
func (c *ContextMock) SetIsConfigured() {}
func (c *ContextMock) IsConfigured() bool {
args := c.Called()
return args.Bool(0)
}
func (c *ContextMock) setRuntime(map[string]string) {}
// Runtime runtime mock
func (c *ContextMock) Runtime() map[string]string {
args := c.Called()
return args.Get(0).(map[string]string)
}
// DB mock
func (c *ContextMock) DB() *gorm.DB {
args := c.Called()
return args.Get(0).(*gorm.DB)
}
// DBTx mock
func (c *ContextMock) DBTx() *gorm.DB {
args := c.Called()
return args.Get(0).(*gorm.DB)
}
// SafeCommit mock
func (c *ContextMock) SafeCommit() {}
// SafeRollback mock
func (c *ContextMock) SafeRollback() {}
// DBTxIsOpen mock
func (c *ContextMock) DBTxIsOpen() bool {
args := c.Called()
return args.Get(0).(bool)
}
func (c *ContextMock) setGinCTX(gCtx *gin.Context) {
}
// GinCtx mock
func (c *ContextMock) GinCtx() *gin.Context {
args := c.Called()
return args.Get(0).(*gin.Context)
}
func (c *ContextMock) setDB(*gorm.DB) {}
func (c *ContextMock) cleanRuntime() {
fmt.Println("123")
}
// GetCurrentUser get current user
func (c *ContextMock) GetCurrentUser() (interface{}, error) {
args := c.Called()
return args.Get(0), args.Error(1)
}
// HTTPStatus mock
func (c *ContextMock) HTTPStatus(code int) {}
// httpResponseUnauthorizedErr mock
func (c *ContextMock) httpResponseUnauthorizedErr(error) {}
// HTTPResponseInternalErr mock
func (c *ContextMock) HTTPResponseInternalErr(error) {}
// httpResponseErr mock
func (c *ContextMock) httpResponseErr(error) {}
// HTTPResponseOk mock
func (c *ContextMock) HTTPResponseOk(interface{}, error) {}
// httpResponseCreated mock
func (c *ContextMock) httpResponseCreated(interface{}, error) {}
// HTTPResponse mock
func (c *ContextMock) HTTPResponse(interface{}, error) {}
// httpResponseDeleted mock
func (c *ContextMock) httpResponseDeleted(res interface{}, err error) {}