-
Notifications
You must be signed in to change notification settings - Fork 134
/
client_moq.go
170 lines (157 loc) · 4.86 KB
/
client_moq.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package events
import (
"context"
"github.com/armadaproject/armada/pkg/api"
"github.com/gogo/protobuf/types"
"sync"
)
// Ensure, that JobEventReaderMock does implement JobEventReader.
// If this is not the case, regenerate this file with moq.
var _ JobEventReader = &JobEventReaderMock{}
// JobEventReaderMock is a mock implementation of JobEventReader.
//
// func TestSomethingThatUsesJobEventReader(t *testing.T) {
//
// // make and configure a mocked JobEventReader
// mockedJobEventReader := &JobEventReaderMock{
// CloseFunc: func() {
// panic("mock out the Close method")
// },
// GetJobEventMessageFunc: func(ctx context.Context, jobReq *api.JobSetRequest) (*api.EventStreamMessage, error) {
// panic("mock out the GetJobEventMessage method")
// },
// HealthFunc: func(ctx context.Context, empty *types.Empty) (*api.HealthCheckResponse, error) {
// panic("mock out the Health method")
// },
// }
//
// // use mockedJobEventReader in code that requires JobEventReader
// // and then make assertions.
//
// }
type JobEventReaderMock struct {
// CloseFunc mocks the Close method.
CloseFunc func()
// GetJobEventMessageFunc mocks the GetJobEventMessage method.
GetJobEventMessageFunc func(ctx context.Context, jobReq *api.JobSetRequest) (*api.EventStreamMessage, error)
// HealthFunc mocks the Health method.
HealthFunc func(ctx context.Context, empty *types.Empty) (*api.HealthCheckResponse, error)
// calls tracks calls to the methods.
calls struct {
// Close holds details about calls to the Close method.
Close []struct {
}
// GetJobEventMessage holds details about calls to the GetJobEventMessage method.
GetJobEventMessage []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// JobReq is the jobReq argument value.
JobReq *api.JobSetRequest
}
// Health holds details about calls to the Health method.
Health []struct {
// Ctx is the ctx argument value.
Ctx context.Context
// Empty is the empty argument value.
Empty *types.Empty
}
}
lockClose sync.RWMutex
lockGetJobEventMessage sync.RWMutex
lockHealth sync.RWMutex
}
// Close calls CloseFunc.
func (mock *JobEventReaderMock) Close() {
if mock.CloseFunc == nil {
panic("JobEventReaderMock.CloseFunc: method is nil but JobEventReader.Close was just called")
}
callInfo := struct {
}{}
mock.lockClose.Lock()
mock.calls.Close = append(mock.calls.Close, callInfo)
mock.lockClose.Unlock()
mock.CloseFunc()
}
// CloseCalls gets all the calls that were made to Close.
// Check the length with:
//
// len(mockedJobEventReader.CloseCalls())
func (mock *JobEventReaderMock) CloseCalls() []struct {
} {
var calls []struct {
}
mock.lockClose.RLock()
calls = mock.calls.Close
mock.lockClose.RUnlock()
return calls
}
// GetJobEventMessage calls GetJobEventMessageFunc.
func (mock *JobEventReaderMock) GetJobEventMessage(ctx context.Context, jobReq *api.JobSetRequest) (*api.EventStreamMessage, error) {
if mock.GetJobEventMessageFunc == nil {
panic("JobEventReaderMock.GetJobEventMessageFunc: method is nil but JobEventReader.GetJobEventMessage was just called")
}
callInfo := struct {
Ctx context.Context
JobReq *api.JobSetRequest
}{
Ctx: ctx,
JobReq: jobReq,
}
mock.lockGetJobEventMessage.Lock()
mock.calls.GetJobEventMessage = append(mock.calls.GetJobEventMessage, callInfo)
mock.lockGetJobEventMessage.Unlock()
return mock.GetJobEventMessageFunc(ctx, jobReq)
}
// GetJobEventMessageCalls gets all the calls that were made to GetJobEventMessage.
// Check the length with:
//
// len(mockedJobEventReader.GetJobEventMessageCalls())
func (mock *JobEventReaderMock) GetJobEventMessageCalls() []struct {
Ctx context.Context
JobReq *api.JobSetRequest
} {
var calls []struct {
Ctx context.Context
JobReq *api.JobSetRequest
}
mock.lockGetJobEventMessage.RLock()
calls = mock.calls.GetJobEventMessage
mock.lockGetJobEventMessage.RUnlock()
return calls
}
// Health calls HealthFunc.
func (mock *JobEventReaderMock) Health(ctx context.Context, empty *types.Empty) (*api.HealthCheckResponse, error) {
if mock.HealthFunc == nil {
panic("JobEventReaderMock.HealthFunc: method is nil but JobEventReader.Health was just called")
}
callInfo := struct {
Ctx context.Context
Empty *types.Empty
}{
Ctx: ctx,
Empty: empty,
}
mock.lockHealth.Lock()
mock.calls.Health = append(mock.calls.Health, callInfo)
mock.lockHealth.Unlock()
return mock.HealthFunc(ctx, empty)
}
// HealthCalls gets all the calls that were made to Health.
// Check the length with:
//
// len(mockedJobEventReader.HealthCalls())
func (mock *JobEventReaderMock) HealthCalls() []struct {
Ctx context.Context
Empty *types.Empty
} {
var calls []struct {
Ctx context.Context
Empty *types.Empty
}
mock.lockHealth.RLock()
calls = mock.calls.Health
mock.lockHealth.RUnlock()
return calls
}