mocks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatcherMock

type MatcherMock struct {
	// MatchMetadataFunc mocks the MatchMetadata method.
	MatchMetadataFunc func(s string, mD metadata.MD) discovery.Matches
	// contains filtered or unexported fields
}

MatcherMock is a mock implementation of proxy.Matcher.

func TestSomethingThatUsesMatcher(t *testing.T) {

	// make and configure a mocked proxy.Matcher
	mockedMatcher := &MatcherMock{
		MatchMetadataFunc: func(s string, mD metadata.MD) discovery.Matches {
			panic("mock out the MatchMetadata method")
		},
	}

	// use mockedMatcher in code that requires proxy.Matcher
	// and then make assertions.

}

func (*MatcherMock) MatchMetadata

func (mock *MatcherMock) MatchMetadata(s string, mD metadata.MD) discovery.Matches

MatchMetadata calls MatchMetadataFunc.

func (*MatcherMock) MatchMetadataCalls

func (mock *MatcherMock) MatchMetadataCalls() []struct {
	S  string
	MD metadata.MD
}

MatchMetadataCalls gets all the calls that were made to MatchMetadata. Check the length with:

len(mockedMatcher.MatchMetadataCalls())

type ServerStreamMock

type ServerStreamMock struct {
	// ContextFunc mocks the Context method.
	ContextFunc func() context.Context

	// RecvMsgFunc mocks the RecvMsg method.
	RecvMsgFunc func(m any) error

	// SendHeaderFunc mocks the SendHeader method.
	SendHeaderFunc func(mD metadata.MD) error

	// SendMsgFunc mocks the SendMsg method.
	SendMsgFunc func(m any) error

	// SetHeaderFunc mocks the SetHeader method.
	SetHeaderFunc func(mD metadata.MD) error

	// SetTrailerFunc mocks the SetTrailer method.
	SetTrailerFunc func(mD metadata.MD)
	// contains filtered or unexported fields
}

ServerStreamMock is a mock implementation of proxy.ServerStream.

func TestSomethingThatUsesServerStream(t *testing.T) {

	// make and configure a mocked proxy.ServerStream
	mockedServerStream := &ServerStreamMock{
		ContextFunc: func() context.Context {
			panic("mock out the Context method")
		},
		RecvMsgFunc: func(m any) error {
			panic("mock out the RecvMsg method")
		},
		SendHeaderFunc: func(mD metadata.MD) error {
			panic("mock out the SendHeader method")
		},
		SendMsgFunc: func(m any) error {
			panic("mock out the SendMsg method")
		},
		SetHeaderFunc: func(mD metadata.MD) error {
			panic("mock out the SetHeader method")
		},
		SetTrailerFunc: func(mD metadata.MD)  {
			panic("mock out the SetTrailer method")
		},
	}

	// use mockedServerStream in code that requires proxy.ServerStream
	// and then make assertions.

}

func (*ServerStreamMock) Context

func (mock *ServerStreamMock) Context() context.Context

Context calls ContextFunc.

func (*ServerStreamMock) ContextCalls

func (mock *ServerStreamMock) ContextCalls() []struct {
}

ContextCalls gets all the calls that were made to Context. Check the length with:

len(mockedServerStream.ContextCalls())

func (*ServerStreamMock) RecvMsg

func (mock *ServerStreamMock) RecvMsg(m any) error

RecvMsg calls RecvMsgFunc.

func (*ServerStreamMock) RecvMsgCalls

func (mock *ServerStreamMock) RecvMsgCalls() []struct {
	M any
}

RecvMsgCalls gets all the calls that were made to RecvMsg. Check the length with:

len(mockedServerStream.RecvMsgCalls())

func (*ServerStreamMock) SendHeader

func (mock *ServerStreamMock) SendHeader(mD metadata.MD) error

SendHeader calls SendHeaderFunc.

func (*ServerStreamMock) SendHeaderCalls

func (mock *ServerStreamMock) SendHeaderCalls() []struct {
	MD metadata.MD
}

SendHeaderCalls gets all the calls that were made to SendHeader. Check the length with:

len(mockedServerStream.SendHeaderCalls())

func (*ServerStreamMock) SendMsg

func (mock *ServerStreamMock) SendMsg(m any) error

SendMsg calls SendMsgFunc.

func (*ServerStreamMock) SendMsgCalls

func (mock *ServerStreamMock) SendMsgCalls() []struct {
	M any
}

SendMsgCalls gets all the calls that were made to SendMsg. Check the length with:

len(mockedServerStream.SendMsgCalls())

func (*ServerStreamMock) SetHeader

func (mock *ServerStreamMock) SetHeader(mD metadata.MD) error

SetHeader calls SetHeaderFunc.

func (*ServerStreamMock) SetHeaderCalls

func (mock *ServerStreamMock) SetHeaderCalls() []struct {
	MD metadata.MD
}

SetHeaderCalls gets all the calls that were made to SetHeader. Check the length with:

len(mockedServerStream.SetHeaderCalls())

func (*ServerStreamMock) SetTrailer

func (mock *ServerStreamMock) SetTrailer(mD metadata.MD)

SetTrailer calls SetTrailerFunc.

func (*ServerStreamMock) SetTrailerCalls

func (mock *ServerStreamMock) SetTrailerCalls() []struct {
	MD metadata.MD
}

SetTrailerCalls gets all the calls that were made to SetTrailer. Check the length with:

len(mockedServerStream.SetTrailerCalls())

Jump to

Keyboard shortcuts

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