-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialer_moq_test.go
75 lines (68 loc) · 1.81 KB
/
dialer_moq_test.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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package amqpx
import (
"context"
"sync"
)
// Ensure, that dialerMock does implement dialer.
// If this is not the case, regenerate this file with moq.
var _ dialer = &dialerMock{}
// dialerMock is a mock implementation of dialer.
//
// func TestSomethingThatUsesdialer(t *testing.T) {
//
// // make and configure a mocked dialer
// mockeddialer := &dialerMock{
// DialFunc: func(contextMoqParam context.Context) (Connection, error) {
// panic("mock out the Dial method")
// },
// }
//
// // use mockeddialer in code that requires dialer
// // and then make assertions.
//
// }
type dialerMock struct {
// DialFunc mocks the Dial method.
DialFunc func(contextMoqParam context.Context) (Connection, error)
// calls tracks calls to the methods.
calls struct {
// Dial holds details about calls to the Dial method.
Dial []struct {
// ContextMoqParam is the contextMoqParam argument value.
ContextMoqParam context.Context
}
}
lockDial sync.RWMutex
}
// Dial calls DialFunc.
func (mock *dialerMock) Dial(contextMoqParam context.Context) (Connection, error) {
if mock.DialFunc == nil {
panic("dialerMock.DialFunc: method is nil but dialer.Dial was just called")
}
callInfo := struct {
ContextMoqParam context.Context
}{
ContextMoqParam: contextMoqParam,
}
mock.lockDial.Lock()
mock.calls.Dial = append(mock.calls.Dial, callInfo)
mock.lockDial.Unlock()
return mock.DialFunc(contextMoqParam)
}
// DialCalls gets all the calls that were made to Dial.
// Check the length with:
//
// len(mockeddialer.DialCalls())
func (mock *dialerMock) DialCalls() []struct {
ContextMoqParam context.Context
} {
var calls []struct {
ContextMoqParam context.Context
}
mock.lockDial.RLock()
calls = mock.calls.Dial
mock.lockDial.RUnlock()
return calls
}