summaryrefslogtreecommitdiff
path: root/api/api_service_mock_test.go
diff options
context:
space:
mode:
authorPhilipp Tanlak <philipp.tanlak@gmail.com>2023-07-27 19:03:41 +0200
committerPhilipp Tanlak <philipp.tanlak@gmail.com>2023-07-27 19:03:41 +0200
commita9b61f84070cc7ca0d6e26f187c745619a91422a (patch)
treed69b67142b6de860d7da23bd5ff8c62af0aaca1e /api/api_service_mock_test.go
init
Diffstat (limited to 'api/api_service_mock_test.go')
-rw-r--r--api/api_service_mock_test.go80
1 files changed, 80 insertions, 0 deletions
diff --git a/api/api_service_mock_test.go b/api/api_service_mock_test.go
new file mode 100644
index 0000000..a7536be
--- /dev/null
+++ b/api/api_service_mock_test.go
@@ -0,0 +1,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
+}