mock

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServerMock

type ServerMock struct {
	// RegisterServiceFunc mocks the RegisterService method.
	RegisterServiceFunc func(sd *grpc2.ServiceDesc, ss interface{})
	// contains filtered or unexported fields
}

ServerMock is a mock implementation of grpc.Server.

func TestSomethingThatUsesServer(t *testing.T) {

	// make and configure a mocked grpc.Server
	mockedServer := &ServerMock{
		RegisterServiceFunc: func(sd *grpc2.ServiceDesc, ss interface{})  {
			panic("mock out the RegisterService method")
		},
	}

	// use mockedServer in code that requires grpc.Server
	// and then make assertions.

}

func (*ServerMock) RegisterService

func (mock *ServerMock) RegisterService(sd *grpc2.ServiceDesc, ss interface{})

RegisterService calls RegisterServiceFunc.

func (*ServerMock) RegisterServiceCalls

func (mock *ServerMock) RegisterServiceCalls() []struct {
	Sd *grpc2.ServiceDesc
	Ss interface{}
}

RegisterServiceCalls gets all the calls that were made to RegisterService. Check the length with:

len(mockedServer.RegisterServiceCalls())

Jump to

Keyboard shortcuts

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