1
0
mirror of https://github.com/umputun/reproxy.git synced 2025-02-16 18:34:30 +02:00
reproxy/app/plugin/client_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

86 lines
2.2 KiB
Go

// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package plugin
import (
"sync"
)
// Ensure, that RPCClientMock does implement RPCClient.
// If this is not the case, regenerate this file with moq.
var _ RPCClient = &RPCClientMock{}
// RPCClientMock is a mock implementation of RPCClient.
//
// func TestSomethingThatUsesRPCClient(t *testing.T) {
//
// // make and configure a mocked RPCClient
// mockedRPCClient := &RPCClientMock{
// CallFunc: func(serviceMethod string, args interface{}, reply interface{}) error {
// panic("mock out the Call method")
// },
// }
//
// // use mockedRPCClient in code that requires RPCClient
// // and then make assertions.
//
// }
type RPCClientMock struct {
// CallFunc mocks the Call method.
CallFunc func(serviceMethod string, args interface{}, reply interface{}) error
// calls tracks calls to the methods.
calls struct {
// Call holds details about calls to the Call method.
Call []struct {
// ServiceMethod is the serviceMethod argument value.
ServiceMethod string
// Args is the args argument value.
Args interface{}
// Reply is the reply argument value.
Reply interface{}
}
}
lockCall sync.RWMutex
}
// Call calls CallFunc.
func (mock *RPCClientMock) Call(serviceMethod string, args interface{}, reply interface{}) error {
if mock.CallFunc == nil {
panic("RPCClientMock.CallFunc: method is nil but RPCClient.Call was just called")
}
callInfo := struct {
ServiceMethod string
Args interface{}
Reply interface{}
}{
ServiceMethod: serviceMethod,
Args: args,
Reply: reply,
}
mock.lockCall.Lock()
mock.calls.Call = append(mock.calls.Call, callInfo)
mock.lockCall.Unlock()
return mock.CallFunc(serviceMethod, args, reply)
}
// CallCalls gets all the calls that were made to Call.
// Check the length with:
// len(mockedRPCClient.CallCalls())
func (mock *RPCClientMock) CallCalls() []struct {
ServiceMethod string
Args interface{}
Reply interface{}
} {
var calls []struct {
ServiceMethod string
Args interface{}
Reply interface{}
}
mock.lockCall.RLock()
calls = mock.calls.Call
mock.lockCall.RUnlock()
return calls
}