forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearcher_mock.go
More file actions
159 lines (146 loc) · 3.97 KB
/
searcher_mock.go
File metadata and controls
159 lines (146 loc) · 3.97 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
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
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package search
import (
"sync"
)
// Ensure, that SearcherMock does implement Searcher.
// If this is not the case, regenerate this file with moq.
var _ Searcher = &SearcherMock{}
// SearcherMock is a mock implementation of Searcher.
//
// func TestSomethingThatUsesSearcher(t *testing.T) {
//
// // make and configure a mocked Searcher
// mockedSearcher := &SearcherMock{
// IssuesFunc: func(query Query) (IssuesResult, error) {
// panic("mock out the Issues method")
// },
// RepositoriesFunc: func(query Query) (RepositoriesResult, error) {
// panic("mock out the Repositories method")
// },
// URLFunc: func(query Query) string {
// panic("mock out the URL method")
// },
// }
//
// // use mockedSearcher in code that requires Searcher
// // and then make assertions.
//
// }
type SearcherMock struct {
// IssuesFunc mocks the Issues method.
IssuesFunc func(query Query) (IssuesResult, error)
// RepositoriesFunc mocks the Repositories method.
RepositoriesFunc func(query Query) (RepositoriesResult, error)
// URLFunc mocks the URL method.
URLFunc func(query Query) string
// calls tracks calls to the methods.
calls struct {
// Issues holds details about calls to the Issues method.
Issues []struct {
// Query is the query argument value.
Query Query
}
// Repositories holds details about calls to the Repositories method.
Repositories []struct {
// Query is the query argument value.
Query Query
}
// URL holds details about calls to the URL method.
URL []struct {
// Query is the query argument value.
Query Query
}
}
lockIssues sync.RWMutex
lockRepositories sync.RWMutex
lockURL sync.RWMutex
}
// Issues calls IssuesFunc.
func (mock *SearcherMock) Issues(query Query) (IssuesResult, error) {
if mock.IssuesFunc == nil {
panic("SearcherMock.IssuesFunc: method is nil but Searcher.Issues was just called")
}
callInfo := struct {
Query Query
}{
Query: query,
}
mock.lockIssues.Lock()
mock.calls.Issues = append(mock.calls.Issues, callInfo)
mock.lockIssues.Unlock()
return mock.IssuesFunc(query)
}
// IssuesCalls gets all the calls that were made to Issues.
// Check the length with:
// len(mockedSearcher.IssuesCalls())
func (mock *SearcherMock) IssuesCalls() []struct {
Query Query
} {
var calls []struct {
Query Query
}
mock.lockIssues.RLock()
calls = mock.calls.Issues
mock.lockIssues.RUnlock()
return calls
}
// Repositories calls RepositoriesFunc.
func (mock *SearcherMock) Repositories(query Query) (RepositoriesResult, error) {
if mock.RepositoriesFunc == nil {
panic("SearcherMock.RepositoriesFunc: method is nil but Searcher.Repositories was just called")
}
callInfo := struct {
Query Query
}{
Query: query,
}
mock.lockRepositories.Lock()
mock.calls.Repositories = append(mock.calls.Repositories, callInfo)
mock.lockRepositories.Unlock()
return mock.RepositoriesFunc(query)
}
// RepositoriesCalls gets all the calls that were made to Repositories.
// Check the length with:
// len(mockedSearcher.RepositoriesCalls())
func (mock *SearcherMock) RepositoriesCalls() []struct {
Query Query
} {
var calls []struct {
Query Query
}
mock.lockRepositories.RLock()
calls = mock.calls.Repositories
mock.lockRepositories.RUnlock()
return calls
}
// URL calls URLFunc.
func (mock *SearcherMock) URL(query Query) string {
if mock.URLFunc == nil {
panic("SearcherMock.URLFunc: method is nil but Searcher.URL was just called")
}
callInfo := struct {
Query Query
}{
Query: query,
}
mock.lockURL.Lock()
mock.calls.URL = append(mock.calls.URL, callInfo)
mock.lockURL.Unlock()
return mock.URLFunc(query)
}
// URLCalls gets all the calls that were made to URL.
// Check the length with:
// len(mockedSearcher.URLCalls())
func (mock *SearcherMock) URLCalls() []struct {
Query Query
} {
var calls []struct {
Query Query
}
mock.lockURL.RLock()
calls = mock.calls.URL
mock.lockURL.RUnlock()
return calls
}