Files
reproxy/app/plugin/dialer_mock.go
2024-05-09 13:16:40 -05:00

81 lines
1.9 KiB
Go

// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package plugin
import (
"sync"
)
// Ensure, that RPCDialerMock does implement RPCDialer.
// If this is not the case, regenerate this file with moq.
var _ RPCDialer = &RPCDialerMock{}
// RPCDialerMock is a mock implementation of RPCDialer.
//
// func TestSomethingThatUsesRPCDialer(t *testing.T) {
//
// // make and configure a mocked RPCDialer
// mockedRPCDialer := &RPCDialerMock{
// DialFunc: func(network string, address string) (RPCClient, error) {
// panic("mock out the Dial method")
// },
// }
//
// // use mockedRPCDialer in code that requires RPCDialer
// // and then make assertions.
//
// }
type RPCDialerMock struct {
// DialFunc mocks the Dial method.
DialFunc func(network string, address string) (RPCClient, error)
// calls tracks calls to the methods.
calls struct {
// Dial holds details about calls to the Dial method.
Dial []struct {
// Network is the network argument value.
Network string
// Address is the address argument value.
Address string
}
}
lockDial sync.RWMutex
}
// Dial calls DialFunc.
func (mock *RPCDialerMock) Dial(network string, address string) (RPCClient, error) {
if mock.DialFunc == nil {
panic("RPCDialerMock.DialFunc: method is nil but RPCDialer.Dial was just called")
}
callInfo := struct {
Network string
Address string
}{
Network: network,
Address: address,
}
mock.lockDial.Lock()
mock.calls.Dial = append(mock.calls.Dial, callInfo)
mock.lockDial.Unlock()
return mock.DialFunc(network, address)
}
// DialCalls gets all the calls that were made to Dial.
// Check the length with:
//
// len(mockedRPCDialer.DialCalls())
func (mock *RPCDialerMock) DialCalls() []struct {
Network string
Address string
} {
var calls []struct {
Network string
Address string
}
mock.lockDial.RLock()
calls = mock.calls.Dial
mock.lockDial.RUnlock()
return calls
}