summaryrefslogblamecommitdiff
path: root/api/api_service_mock_test.go
blob: a7536beea791315075cf1308a68e10a131e8dac0 (plain) (tree)















































































                                                                                                       
// 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
}