utils

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(address string, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)

Connect address by grpc

func Protobuf added in v5.3.1

func Protobuf(msg proto.Message) gomock.Matcher

Protobuf returns a Matcher that relies upon proto.Equal to compare Protobuf messages Example usage with mocked request:

example.EXPECT().ExampleRequest(Protobuf(requestMsg)).Return(responseMsg, nil).AnyTimes()

Types

type ProtobufMatcher added in v5.3.1

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

func (*ProtobufMatcher) Matches added in v5.3.1

func (p *ProtobufMatcher) Matches(x interface{}) bool

func (*ProtobufMatcher) String added in v5.3.1

func (p *ProtobufMatcher) String() string

type SafeGoroutineTester

type SafeGoroutineTester struct{}

SafeGoroutineTester is an implementation of the mock ... interface which can be used to use the mock functions in another go routine.

The major issue is that the golang mock framework uses t.Fatalf() which causes a deadlock when called in another goroutine. To avoid this issue, this simple implementation prints the error then panics, which avoids the deadlock.

func (*SafeGoroutineTester) Errorf

func (s *SafeGoroutineTester) Errorf(format string, args ...interface{})

Errorf prints the error to the screen then panics

func (*SafeGoroutineTester) Fatalf

func (s *SafeGoroutineTester) Fatalf(format string, args ...interface{})

Fatalf prints the error to the screen then panics

Jump to

Keyboard shortcuts

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