1
0
mirror of https://github.com/umputun/reproxy.git synced 2025-02-22 18:42:01 +02:00
reproxy/app/plugin/dialer_mock.go
Umputun 7139c57766
RPC plugins support (#85)
* wip

* resolve merge artifacts

* full coverage for conductor

* wire plugin conductor to main and proxy

* wip, with separate match handler

* split matching logic with another handler, add initial docs

* move parts of proxy to handlers, add tests

* add headers in to be sent to proxied url

* merged from master

* add example with docker compose

* supress excesive debug reporting 0-9 disabled in docker

* add plugin tests

* randomize test port

* lint: minor warns

* lint: err shadow
2021-06-01 02:56:39 -05:00

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