-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdispatcher_test.go
More file actions
77 lines (69 loc) · 1.81 KB
/
dispatcher_test.go
File metadata and controls
77 lines (69 loc) · 1.81 KB
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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package slice
import (
"context"
"sync"
)
var (
lockDispatcherMockRun sync.RWMutex
)
// Ensure, that DispatcherMock does implement Dispatcher.
// If this is not the case, regenerate this file with moq.
var _ Dispatcher = &DispatcherMock{}
// DispatcherMock is a mock implementation of Dispatcher.
//
// func TestSomethingThatUsesDispatcher(t *testing.T) {
//
// // make and configure a mocked Dispatcher
// mockedDispatcher := &DispatcherMock{
// RunFunc: func(ctx context.Context) error {
// panic("mock out the Run method")
// },
// }
//
// // use mockedDispatcher in code that requires Dispatcher
// // and then make assertions.
//
// }
type DispatcherMock struct {
// RunFunc mocks the Run method.
RunFunc func(ctx context.Context) error
// calls tracks calls to the methods.
calls struct {
// Run holds details about calls to the Run method.
Run []struct {
// Ctx is the ctx argument value.
Ctx context.Context
}
}
}
// Run calls RunFunc.
func (mock *DispatcherMock) Run(ctx context.Context) error {
if mock.RunFunc == nil {
panic("DispatcherMock.RunFunc: method is nil but Dispatcher.Run was just called")
}
callInfo := struct {
Ctx context.Context
}{
Ctx: ctx,
}
lockDispatcherMockRun.Lock()
mock.calls.Run = append(mock.calls.Run, callInfo)
lockDispatcherMockRun.Unlock()
return mock.RunFunc(ctx)
}
// RunCalls gets all the calls that were made to Run.
// Check the length with:
// len(mockedDispatcher.RunCalls())
func (mock *DispatcherMock) RunCalls() []struct {
Ctx context.Context
} {
var calls []struct {
Ctx context.Context
}
lockDispatcherMockRun.RLock()
calls = mock.calls.Run
lockDispatcherMockRun.RUnlock()
return calls
}