mocks

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

Running Prerequisites

  • Run command go install github.com/golang/mock/mockgen@latest to install gomock
  • Run command git clone github.com/cloudwego/netpoll to clone netpoll in the parent directory of kitex.

User's Guidance

  • Add a line under the files parameter of update.sh.
  • Fill in the go file path where the interface you want to mock is located.
  • Fill in the path of the output mock file.
  • Fill in the package name of the output mock file.
  • Run sh update.sh to update mock files.
  • Now you can use the generated gomock class to mock interface. Refer to https://github.com/golang/mock.

Documentation

Overview

Package mocks contains mocks of interfaces.

Index

Constants

View Source
const (
	MockServiceName            = "MockService"
	MockService2Name           = "MockService2"
	MockService3Name           = "MockService3"
	MockMethod          string = "mock"
	Mock2Method         string = "mock2"
	MockExceptionMethod string = "mockException"
	MockErrorMethod     string = "mockError"
	MockOnewayMethod    string = "mockOneway"
	MockStreamingMethod string = "mockStreaming"
)

method name of mock

Variables

This section is empty.

Functions

func MockFuncHandler

func MockFuncHandler(mf func(ctx context.Context, req *MyRequest) (r *MyResponse, err error)) interface{}

MockFuncHandler .

func MyServiceHandler

func MyServiceHandler() interface{}

MyServiceHandler .

func NewMockArgs

func NewMockArgs() interface{}

func NewMockCliTransHandlerFactory

func NewMockCliTransHandlerFactory(hdrl *MockCliTransHandler) remote.ClientTransHandlerFactory

NewMockCliTransHandlerFactory .

func NewMockResult

func NewMockResult() interface{}

func NewMockSvrTransHandlerFactory

func NewMockSvrTransHandlerFactory(hdrl *MockSvrTransHandler) remote.ServerTransHandlerFactory

NewMockSvrTransHandlerFactory .

func NewMockTransServerFactory

func NewMockTransServerFactory(transSvr *MockTransServer) remote.TransServerFactory

NewMockTransServerFactory .

func Service2Info added in v0.8.0

func Service2Info() *serviceinfo.ServiceInfo

Service2Info return mock serviceInfo

func Service3Info added in v0.9.0

func Service3Info() *serviceinfo.ServiceInfo

Service3Info return mock serviceInfo

func ServiceInfo

func ServiceInfo() *serviceinfo.ServiceInfo

ServiceInfo return mock serviceInfo

Types

type Conn

type Conn struct {
	ReadFunc             func(b []byte) (n int, err error)
	WriteFunc            func(b []byte) (n int, err error)
	CloseFunc            func() (e error)
	LocalAddrFunc        func() (r net.Addr)
	RemoteAddrFunc       func() (r net.Addr)
	SetDeadlineFunc      func(t time.Time) (e error)
	SetReadDeadlineFunc  func(t time.Time) (e error)
	SetWriteDeadlineFunc func(t time.Time) (e error)
}

Conn implements the net.Conn interface.

func NewIOConn added in v0.11.0

func NewIOConn() *Conn

func (Conn) Close

func (m Conn) Close() (e error)

Close implements the net.Conn interface.

func (Conn) LocalAddr

func (m Conn) LocalAddr() (r net.Addr)

LocalAddr implements the net.Conn interface.

func (Conn) Read

func (m Conn) Read(b []byte) (n int, err error)

Read implements the net.Conn interface.

func (Conn) RemoteAddr

func (m Conn) RemoteAddr() (r net.Addr)

RemoteAddr implements the net.Conn interface.

func (Conn) SetDeadline

func (m Conn) SetDeadline(t time.Time) (e error)

SetDeadline implements the net.Conn interface.

func (Conn) SetReadDeadline

func (m Conn) SetReadDeadline(t time.Time) (e error)

SetReadDeadline implements the net.Conn interface.

func (Conn) SetWriteDeadline

func (m Conn) SetWriteDeadline(t time.Time) (e error)

SetWriteDeadline implements the net.Conn interface.

func (Conn) Write

func (m Conn) Write(b []byte) (n int, err error)

Write implements the net.Conn interface.

type MockCliTransHandler

type MockCliTransHandler struct {
	WriteFunc func(ctx context.Context, conn net.Conn, send remote.Message) (nctx context.Context, err error)

	ReadFunc func(ctx context.Context, conn net.Conn, msg remote.Message) (nctx context.Context, err error)

	OnMessageFunc func(ctx context.Context, args, result remote.Message) (context.Context, error)
	// contains filtered or unexported fields
}

MockCliTransHandler .

func (*MockCliTransHandler) OnActive

func (t *MockCliTransHandler) OnActive(ctx context.Context, conn net.Conn) (context.Context, error)

OnActive implements the remote.TransHandler interface.

func (*MockCliTransHandler) OnError

func (t *MockCliTransHandler) OnError(ctx context.Context, err error, conn net.Conn)

OnError implements the remote.TransHandler interface.

func (*MockCliTransHandler) OnInactive

func (t *MockCliTransHandler) OnInactive(ctx context.Context, conn net.Conn)

OnInactive implements the remote.TransHandler interface.

func (*MockCliTransHandler) OnMessage

func (t *MockCliTransHandler) OnMessage(ctx context.Context, args, result remote.Message) (context.Context, error)

OnMessage implements the remote.TransHandler interface.

func (*MockCliTransHandler) Read

func (t *MockCliTransHandler) Read(ctx context.Context, conn net.Conn, msg remote.Message) (nctx context.Context, err error)

Read implements the remote.TransHandler interface.

func (*MockCliTransHandler) SetPipeline

func (t *MockCliTransHandler) SetPipeline(p *remote.TransPipeline)

SetPipeline implements the remote.TransHandler interface.

func (*MockCliTransHandler) Write

func (t *MockCliTransHandler) Write(ctx context.Context, conn net.Conn, send remote.Message) (nctx context.Context, err error)

Write implements the remote.TransHandler interface.

type MockSvrTransHandler

type MockSvrTransHandler struct {
	Opt *remote.ServerOption

	OnReadFunc func(ctx context.Context, conn net.Conn) error

	WriteFunc func(ctx context.Context, conn net.Conn, send remote.Message) (nctx context.Context, err error)

	ReadFunc func(ctx context.Context, conn net.Conn, msg remote.Message) (nctx context.Context, err error)
	// contains filtered or unexported fields
}

MockSvrTransHandler .

func (*MockSvrTransHandler) OnActive

func (t *MockSvrTransHandler) OnActive(ctx context.Context, conn net.Conn) (context.Context, error)

OnActive implements the remote.TransHandler interface.

func (*MockSvrTransHandler) OnError

func (t *MockSvrTransHandler) OnError(ctx context.Context, err error, conn net.Conn)

OnError implements the remote.TransHandler interface.

func (*MockSvrTransHandler) OnInactive

func (t *MockSvrTransHandler) OnInactive(ctx context.Context, conn net.Conn)

OnInactive implements the remote.TransHandler interface.

func (*MockSvrTransHandler) OnMessage

func (t *MockSvrTransHandler) OnMessage(ctx context.Context, args, result remote.Message) (context.Context, error)

OnMessage implements the remote.TransHandler interface.

func (*MockSvrTransHandler) OnRead

func (t *MockSvrTransHandler) OnRead(ctx context.Context, conn net.Conn) (err error)

OnRead implements the remote.TransHandler interface.

func (*MockSvrTransHandler) Read

func (t *MockSvrTransHandler) Read(ctx context.Context, conn net.Conn, msg remote.Message) (nctx context.Context, err error)

Read implements the remote.TransHandler interface.

func (*MockSvrTransHandler) SetPipeline

func (t *MockSvrTransHandler) SetPipeline(p *remote.TransPipeline)

SetPipeline implements the remote.TransHandler interface.

func (*MockSvrTransHandler) Write

func (t *MockSvrTransHandler) Write(ctx context.Context, conn net.Conn, send remote.Message) (nctx context.Context, err error)

Write implements the remote.TransHandler interface.

type MockTransServer

type MockTransServer struct {
	CreateListenerFunc  func(net.Addr) (net.Listener, error)
	BootstrapServerFunc func(net.Listener) (err error)
	ShutdownFunc        func() (err error)
	ConnCountFunc       func() utils.AtomicInt
	// contains filtered or unexported fields
}

MockTransServer .

func (*MockTransServer) BootstrapServer

func (t *MockTransServer) BootstrapServer(ln net.Listener) (err error)

BootstrapServer .

func (*MockTransServer) ConnCount

func (t *MockTransServer) ConnCount() (r utils.AtomicInt)

ConnCount .

func (*MockTransServer) CreateListener

func (t *MockTransServer) CreateListener(addr net.Addr) (ln net.Listener, err error)

CreateListener .

func (*MockTransServer) Shutdown

func (t *MockTransServer) Shutdown() (err error)

Shutdown .

type MockTransServerFactory

type MockTransServerFactory struct {
	// contains filtered or unexported fields
}

MockTransServerFactory .

func (*MockTransServerFactory) NewTransServer

NewTransServer .

type MyException

type MyException struct {
	Message string `thrift:"message,1" json:"message"`
}

MyException .

func (*MyException) Error

func (p *MyException) Error() string

type MyRequest

type MyRequest struct {
	Name string `thrift:"Name,1" json:"Name"`
}

MyRequest .

type MyResponse

type MyResponse struct {
	Name string `thrift:"Name,1" json:"Name"`
}

MyResponse .

type MyService

type MyService interface {
	Mock(ctx context.Context, req *MyRequest) (r *MyResponse, err error)
	MockException(ctx context.Context, req *MyRequest) (r *MyResponse, err error)
	MockError(ctx context.Context, req *MyRequest) (r *MyResponse, err error)
	MockOneway(ctx context.Context, req *MyRequest) (err error)
	Mock2(ctx context.Context, req *MyRequest) (r *MyResponse, err error)
}

MyService .

Directories

Path Synopsis
Package remote is a generated GoMock package.
Package remote is a generated GoMock package.
Package discovery is a generated GoMock package.
Package discovery is a generated GoMock package.
Package generic is a generated GoMock package.
Package generic is a generated GoMock package.
Package klog is a generated GoMock package.
Package klog is a generated GoMock package.
Package limiter is a generated GoMock package.
Package limiter is a generated GoMock package.
Package loadbalance is a generated GoMock package.
Package loadbalance is a generated GoMock package.
Package net is a generated GoMock package.
Package net is a generated GoMock package.
Package netpoll is a generated GoMock package.
Package netpoll is a generated GoMock package.
proto
kitex_gen/pbapi/mock
Code generated by Kitex v0.9.1.
Code generated by Kitex v0.9.1.
Package proxy is a generated GoMock package.
Package proxy is a generated GoMock package.
Package remote is a generated GoMock package.
Package remote is a generated GoMock package.
Package rpc_info is a generated GoMock package.
Package rpc_info is a generated GoMock package.
Package stats is a generated GoMock package.
Package stats is a generated GoMock package.
Package utils is a generated GoMock package.
Package utils is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL