youtube.go
7403 bytes
1// Code generated by moq; DO NOT EDIT.
2// github.com/matryer/moq
3
4package youtube_mock
5
6import (
7 "context"
8 "github.com/TheEdgeOfRage/ytrssil-api/lib/clients/youtube"
9 "github.com/TheEdgeOfRage/ytrssil-api/models"
10 "sync"
11)
12
13// Ensure, that ClientMock does implement youtube.Client.
14// If this is not the case, regenerate this file with moq.
15var _ youtube.Client = &ClientMock{}
16
17// ClientMock is a mock implementation of youtube.Client.
18//
19// func TestSomethingThatUsesClient(t *testing.T) {
20//
21// // make and configure a mocked youtube.Client
22// mockedClient := &ClientMock{
23// GetChannelImageURLFunc: func(ctx context.Context, channelID string) (string, error) {
24// panic("mock out the GetChannelImageURL method")
25// },
26// GetVideoDurationsFunc: func(ctx context.Context, videos map[string]*models.Video) error {
27// panic("mock out the GetVideoDurations method")
28// },
29// GetVideoMetadataFunc: func(ctx context.Context, videoID string) (*models.Video, error) {
30// panic("mock out the GetVideoMetadata method")
31// },
32// ResolveChannelIDFunc: func(ctx context.Context, handle string) (string, error) {
33// panic("mock out the ResolveChannelID method")
34// },
35// }
36//
37// // use mockedClient in code that requires youtube.Client
38// // and then make assertions.
39//
40// }
41type ClientMock struct {
42 // GetChannelImageURLFunc mocks the GetChannelImageURL method.
43 GetChannelImageURLFunc func(ctx context.Context, channelID string) (string, error)
44
45 // GetVideoDurationsFunc mocks the GetVideoDurations method.
46 GetVideoDurationsFunc func(ctx context.Context, videos map[string]*models.Video) error
47
48 // GetVideoMetadataFunc mocks the GetVideoMetadata method.
49 GetVideoMetadataFunc func(ctx context.Context, videoID string) (*models.Video, error)
50
51 // ResolveChannelIDFunc mocks the ResolveChannelID method.
52 ResolveChannelIDFunc func(ctx context.Context, handle string) (string, error)
53
54 // calls tracks calls to the methods.
55 calls struct {
56 // GetChannelImageURL holds details about calls to the GetChannelImageURL method.
57 GetChannelImageURL []struct {
58 // Ctx is the ctx argument value.
59 Ctx context.Context
60 // ChannelID is the channelID argument value.
61 ChannelID string
62 }
63 // GetVideoDurations holds details about calls to the GetVideoDurations method.
64 GetVideoDurations []struct {
65 // Ctx is the ctx argument value.
66 Ctx context.Context
67 // Videos is the videos argument value.
68 Videos map[string]*models.Video
69 }
70 // GetVideoMetadata holds details about calls to the GetVideoMetadata method.
71 GetVideoMetadata []struct {
72 // Ctx is the ctx argument value.
73 Ctx context.Context
74 // VideoID is the videoID argument value.
75 VideoID string
76 }
77 // ResolveChannelID holds details about calls to the ResolveChannelID method.
78 ResolveChannelID []struct {
79 // Ctx is the ctx argument value.
80 Ctx context.Context
81 // Handle is the handle argument value.
82 Handle string
83 }
84 }
85 lockGetChannelImageURL sync.RWMutex
86 lockGetVideoDurations sync.RWMutex
87 lockGetVideoMetadata sync.RWMutex
88 lockResolveChannelID sync.RWMutex
89}
90
91// GetChannelImageURL calls GetChannelImageURLFunc.
92func (mock *ClientMock) GetChannelImageURL(ctx context.Context, channelID string) (string, error) {
93 if mock.GetChannelImageURLFunc == nil {
94 panic("ClientMock.GetChannelImageURLFunc: method is nil but Client.GetChannelImageURL was just called")
95 }
96 callInfo := struct {
97 Ctx context.Context
98 ChannelID string
99 }{
100 Ctx: ctx,
101 ChannelID: channelID,
102 }
103 mock.lockGetChannelImageURL.Lock()
104 mock.calls.GetChannelImageURL = append(mock.calls.GetChannelImageURL, callInfo)
105 mock.lockGetChannelImageURL.Unlock()
106 return mock.GetChannelImageURLFunc(ctx, channelID)
107}
108
109// GetChannelImageURLCalls gets all the calls that were made to GetChannelImageURL.
110// Check the length with:
111//
112// len(mockedClient.GetChannelImageURLCalls())
113func (mock *ClientMock) GetChannelImageURLCalls() []struct {
114 Ctx context.Context
115 ChannelID string
116} {
117 var calls []struct {
118 Ctx context.Context
119 ChannelID string
120 }
121 mock.lockGetChannelImageURL.RLock()
122 calls = mock.calls.GetChannelImageURL
123 mock.lockGetChannelImageURL.RUnlock()
124 return calls
125}
126
127// GetVideoDurations calls GetVideoDurationsFunc.
128func (mock *ClientMock) GetVideoDurations(ctx context.Context, videos map[string]*models.Video) error {
129 if mock.GetVideoDurationsFunc == nil {
130 panic("ClientMock.GetVideoDurationsFunc: method is nil but Client.GetVideoDurations was just called")
131 }
132 callInfo := struct {
133 Ctx context.Context
134 Videos map[string]*models.Video
135 }{
136 Ctx: ctx,
137 Videos: videos,
138 }
139 mock.lockGetVideoDurations.Lock()
140 mock.calls.GetVideoDurations = append(mock.calls.GetVideoDurations, callInfo)
141 mock.lockGetVideoDurations.Unlock()
142 return mock.GetVideoDurationsFunc(ctx, videos)
143}
144
145// GetVideoDurationsCalls gets all the calls that were made to GetVideoDurations.
146// Check the length with:
147//
148// len(mockedClient.GetVideoDurationsCalls())
149func (mock *ClientMock) GetVideoDurationsCalls() []struct {
150 Ctx context.Context
151 Videos map[string]*models.Video
152} {
153 var calls []struct {
154 Ctx context.Context
155 Videos map[string]*models.Video
156 }
157 mock.lockGetVideoDurations.RLock()
158 calls = mock.calls.GetVideoDurations
159 mock.lockGetVideoDurations.RUnlock()
160 return calls
161}
162
163// GetVideoMetadata calls GetVideoMetadataFunc.
164func (mock *ClientMock) GetVideoMetadata(ctx context.Context, videoID string) (*models.Video, error) {
165 if mock.GetVideoMetadataFunc == nil {
166 panic("ClientMock.GetVideoMetadataFunc: method is nil but Client.GetVideoMetadata was just called")
167 }
168 callInfo := struct {
169 Ctx context.Context
170 VideoID string
171 }{
172 Ctx: ctx,
173 VideoID: videoID,
174 }
175 mock.lockGetVideoMetadata.Lock()
176 mock.calls.GetVideoMetadata = append(mock.calls.GetVideoMetadata, callInfo)
177 mock.lockGetVideoMetadata.Unlock()
178 return mock.GetVideoMetadataFunc(ctx, videoID)
179}
180
181// GetVideoMetadataCalls gets all the calls that were made to GetVideoMetadata.
182// Check the length with:
183//
184// len(mockedClient.GetVideoMetadataCalls())
185func (mock *ClientMock) GetVideoMetadataCalls() []struct {
186 Ctx context.Context
187 VideoID string
188} {
189 var calls []struct {
190 Ctx context.Context
191 VideoID string
192 }
193 mock.lockGetVideoMetadata.RLock()
194 calls = mock.calls.GetVideoMetadata
195 mock.lockGetVideoMetadata.RUnlock()
196 return calls
197}
198
199// ResolveChannelID calls ResolveChannelIDFunc.
200func (mock *ClientMock) ResolveChannelID(ctx context.Context, handle string) (string, error) {
201 if mock.ResolveChannelIDFunc == nil {
202 panic("ClientMock.ResolveChannelIDFunc: method is nil but Client.ResolveChannelID was just called")
203 }
204 callInfo := struct {
205 Ctx context.Context
206 Handle string
207 }{
208 Ctx: ctx,
209 Handle: handle,
210 }
211 mock.lockResolveChannelID.Lock()
212 mock.calls.ResolveChannelID = append(mock.calls.ResolveChannelID, callInfo)
213 mock.lockResolveChannelID.Unlock()
214 return mock.ResolveChannelIDFunc(ctx, handle)
215}
216
217// ResolveChannelIDCalls gets all the calls that were made to ResolveChannelID.
218// Check the length with:
219//
220// len(mockedClient.ResolveChannelIDCalls())
221func (mock *ClientMock) ResolveChannelIDCalls() []struct {
222 Ctx context.Context
223 Handle string
224} {
225 var calls []struct {
226 Ctx context.Context
227 Handle string
228 }
229 mock.lockResolveChannelID.RLock()
230 calls = mock.calls.ResolveChannelID
231 mock.lockResolveChannelID.RUnlock()
232 return calls
233}