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
|
// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package api
import (
"sync"
)
// Ensure, that ServiceMock does implement Service.
// If this is not the case, regenerate this file with moq.
var _ Service = &ServiceMock{}
// ServiceMock is a mock implementation of Service.
//
// func TestSomethingThatUsesService(t *testing.T) {
//
// // make and configure a mocked Service
// mockedService := &ServiceMock{
// ScrapeURLFunc: func(url string, params map[string]any) (any, error) {
// panic("mock out the ScrapeURL method")
// },
// }
//
// // use mockedService in code that requires Service
// // and then make assertions.
//
// }
type ServiceMock struct {
// ScrapeURLFunc mocks the ScrapeURL method.
ScrapeURLFunc func(url string, params map[string]any) (any, error)
// calls tracks calls to the methods.
calls struct {
// ScrapeURL holds details about calls to the ScrapeURL method.
ScrapeURL []struct {
// URL is the url argument value.
URL string
// Params is the params argument value.
Params map[string]any
}
}
lockScrapeURL sync.RWMutex
}
// ScrapeURL calls ScrapeURLFunc.
func (mock *ServiceMock) ScrapeURL(url string, params map[string]any) (any, error) {
if mock.ScrapeURLFunc == nil {
panic("ServiceMock.ScrapeURLFunc: method is nil but Service.ScrapeURL was just called")
}
callInfo := struct {
URL string
Params map[string]any
}{
URL: url,
Params: params,
}
mock.lockScrapeURL.Lock()
mock.calls.ScrapeURL = append(mock.calls.ScrapeURL, callInfo)
mock.lockScrapeURL.Unlock()
return mock.ScrapeURLFunc(url, params)
}
// ScrapeURLCalls gets all the calls that were made to ScrapeURL.
// Check the length with:
//
// len(mockedService.ScrapeURLCalls())
func (mock *ServiceMock) ScrapeURLCalls() []struct {
URL string
Params map[string]any
} {
var calls []struct {
URL string
Params map[string]any
}
mock.lockScrapeURL.RLock()
calls = mock.calls.ScrapeURL
mock.lockScrapeURL.RUnlock()
return calls
}
|