1
0
mirror of https://github.com/umputun/reproxy.git synced 2025-11-29 22:08:14 +02:00
Files
reproxy/app/discovery/provider/docker_client_mock.go
2021-04-01 02:37:28 -05:00

115 lines
3.6 KiB
Go

// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package provider
import (
"sync"
dclient "github.com/fsouza/go-dockerclient"
)
// DockerClientMock is a mock implementation of DockerClient.
//
// func TestSomethingThatUsesDockerClient(t *testing.T) {
//
// // make and configure a mocked DockerClient
// mockedDockerClient := &DockerClientMock{
// AddEventListenerFunc: func(listener chan<- *dclient.APIEvents) error {
// panic("mock out the AddEventListener method")
// },
// ListContainersFunc: func(opts dclient.ListContainersOptions) ([]dclient.APIContainers, error) {
// panic("mock out the ListContainers method")
// },
// }
//
// // use mockedDockerClient in code that requires DockerClient
// // and then make assertions.
//
// }
type DockerClientMock struct {
// AddEventListenerFunc mocks the AddEventListener method.
AddEventListenerFunc func(listener chan<- *dclient.APIEvents) error
// ListContainersFunc mocks the ListContainers method.
ListContainersFunc func(opts dclient.ListContainersOptions) ([]dclient.APIContainers, error)
// calls tracks calls to the methods.
calls struct {
// AddEventListener holds details about calls to the AddEventListener method.
AddEventListener []struct {
// Listener is the listener argument value.
Listener chan<- *dclient.APIEvents
}
// ListContainers holds details about calls to the ListContainers method.
ListContainers []struct {
// Opts is the opts argument value.
Opts dclient.ListContainersOptions
}
}
lockAddEventListener sync.RWMutex
lockListContainers sync.RWMutex
}
// AddEventListener calls AddEventListenerFunc.
func (mock *DockerClientMock) AddEventListener(listener chan<- *dclient.APIEvents) error {
if mock.AddEventListenerFunc == nil {
panic("DockerClientMock.AddEventListenerFunc: method is nil but DockerClient.AddEventListener was just called")
}
callInfo := struct {
Listener chan<- *dclient.APIEvents
}{
Listener: listener,
}
mock.lockAddEventListener.Lock()
mock.calls.AddEventListener = append(mock.calls.AddEventListener, callInfo)
mock.lockAddEventListener.Unlock()
return mock.AddEventListenerFunc(listener)
}
// AddEventListenerCalls gets all the calls that were made to AddEventListener.
// Check the length with:
// len(mockedDockerClient.AddEventListenerCalls())
func (mock *DockerClientMock) AddEventListenerCalls() []struct {
Listener chan<- *dclient.APIEvents
} {
var calls []struct {
Listener chan<- *dclient.APIEvents
}
mock.lockAddEventListener.RLock()
calls = mock.calls.AddEventListener
mock.lockAddEventListener.RUnlock()
return calls
}
// ListContainers calls ListContainersFunc.
func (mock *DockerClientMock) ListContainers(opts dclient.ListContainersOptions) ([]dclient.APIContainers, error) {
if mock.ListContainersFunc == nil {
panic("DockerClientMock.ListContainersFunc: method is nil but DockerClient.ListContainers was just called")
}
callInfo := struct {
Opts dclient.ListContainersOptions
}{
Opts: opts,
}
mock.lockListContainers.Lock()
mock.calls.ListContainers = append(mock.calls.ListContainers, callInfo)
mock.lockListContainers.Unlock()
return mock.ListContainersFunc(opts)
}
// ListContainersCalls gets all the calls that were made to ListContainers.
// Check the length with:
// len(mockedDockerClient.ListContainersCalls())
func (mock *DockerClientMock) ListContainersCalls() []struct {
Opts dclient.ListContainersOptions
} {
var calls []struct {
Opts dclient.ListContainersOptions
}
mock.lockListContainers.RLock()
calls = mock.calls.ListContainers
mock.lockListContainers.RUnlock()
return calls
}