-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathmocks_test.go
93 lines (86 loc) · 2.48 KB
/
mocks_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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package consul
import (
"github.com/hashicorp/consul/api"
"sync"
)
// Ensure, that servicerMock does implement servicer.
// If this is not the case, regenerate this file with moq.
var _ servicer = &servicerMock{}
// servicerMock is a mock implementation of servicer.
//
// func TestSomethingThatUsesservicer(t *testing.T) {
//
// // make and configure a mocked servicer
// mockedservicer := &servicerMock{
// ServiceFunc: func(s1 string, s2 string, b bool, queryOptions *api.QueryOptions) ([]*api.ServiceEntry, *api.QueryMeta, error) {
// panic("mock out the Service method")
// },
// }
//
// // use mockedservicer in code that requires servicer
// // and then make assertions.
//
// }
type servicerMock struct {
// ServiceFunc mocks the Service method.
ServiceFunc func(s1 string, s2 string, b bool, queryOptions *api.QueryOptions) ([]*api.ServiceEntry, *api.QueryMeta, error)
// calls tracks calls to the methods.
calls struct {
// Service holds details about calls to the Service method.
Service []struct {
// S1 is the s1 argument value.
S1 string
// S2 is the s2 argument value.
S2 string
// B is the b argument value.
B bool
// QueryOptions is the queryOptions argument value.
QueryOptions *api.QueryOptions
}
}
lockService sync.RWMutex
}
// Service calls ServiceFunc.
func (mock *servicerMock) Service(s1 string, s2 string, b bool, queryOptions *api.QueryOptions) ([]*api.ServiceEntry, *api.QueryMeta, error) {
if mock.ServiceFunc == nil {
panic("servicerMock.ServiceFunc: method is nil but servicer.Service was just called")
}
callInfo := struct {
S1 string
S2 string
B bool
QueryOptions *api.QueryOptions
}{
S1: s1,
S2: s2,
B: b,
QueryOptions: queryOptions,
}
mock.lockService.Lock()
mock.calls.Service = append(mock.calls.Service, callInfo)
mock.lockService.Unlock()
return mock.ServiceFunc(s1, s2, b, queryOptions)
}
// ServiceCalls gets all the calls that were made to Service.
// Check the length with:
//
// len(mockedservicer.ServiceCalls())
func (mock *servicerMock) ServiceCalls() []struct {
S1 string
S2 string
B bool
QueryOptions *api.QueryOptions
} {
var calls []struct {
S1 string
S2 string
B bool
QueryOptions *api.QueryOptions
}
mock.lockService.RLock()
calls = mock.calls.Service
mock.lockService.RUnlock()
return calls
}