-
Notifications
You must be signed in to change notification settings - Fork 2
/
context_mock.go
98 lines (81 loc) · 1.94 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
package core
import (
"github.com/pskclub/mine-core/consts"
"github.com/stretchr/testify/mock"
"gorm.io/gorm"
)
func NewMockContext() *ContextMock {
return &ContextMock{
MockRequester: NewMockRequester(),
MockCache: NewMockCache(),
MockMQ: NewMockMQ(),
MockLog: NewMockLogger(),
MockDBMongo: NewMockMongoDB(),
MockDB: NewMockDatabase(),
}
}
type ContextMock struct {
mock.Mock
MockRequester *MockRequester
MockCache *MockCache
MockMQ *MockMQ
MockLog *MockLogger
MockDBMongo *MockMongoDB
MockDB *MockDatabase
}
func (m *ContextMock) Cache() ICache {
args := m.Called()
return args.Get(0).(ICache)
}
func (m *ContextMock) ELS() IELS {
args := m.Called()
return args.Get(0).(IELS)
}
func (m *ContextMock) MQ() IMQ {
args := m.Called()
return args.Get(0).(IMQ)
}
func (m *ContextMock) Caches(name string) ICache {
args := m.Called(name)
return args.Get(0).(ICache)
}
func (m *ContextMock) Requester() IRequester {
args := m.Called()
return args.Get(0).(IRequester)
}
func (m *ContextMock) SetType(t consts.ContextType) {
m.Called(t)
}
// Log return the logger
func (m *ContextMock) Log() ILogger {
args := m.Called()
return args.Get(0).(ILogger)
}
func (m *ContextMock) Type() string {
args := m.Called()
return args.Get(0).(string)
}
func (m *ContextMock) DB() *gorm.DB {
args := m.Called()
return args.Get(0).(*gorm.DB)
}
func (m *ContextMock) DBS(name string) *gorm.DB {
args := m.Called(name)
return args.Get(0).(*gorm.DB)
}
func (m *ContextMock) DBMongo() IMongoDB {
args := m.Called()
return args.Get(0).(IMongoDB)
}
func (m *ContextMock) DBSMongo(name string) IMongoDB {
args := m.Called(name)
return args.Get(0).(IMongoDB)
}
func (m *ContextMock) NewError(err error, errorType IError, args ...interface{}) IError {
args2 := m.Called(err, errorType, args)
return MockIError(args2, 0)
}
func (m *ContextMock) ENV() IENV {
args := m.Called()
return args.Get(0).(IENV)
}