Documentation
¶
Index ¶
- func Context(tb testing.TB) context.Context
- func ContextWithTimeout(tb testing.TB, timeout time.Duration) context.Context
- func MustMarshal[T proto.Message](t testingT, r *ads.Resource[T]) *ads.RawResource
- func ProtoEquals(t testingT, expected, actual proto.Message)
- func ResourceEquals[T proto.Message](t testingT, expected, actual *ads.Resource[T])
- func WithTimeout(t *testing.T, name string, timeout time.Duration, f func(t *testing.T))
- type ChanSubscriptionHandler
- func (c ChanSubscriptionHandler[T]) Notify(name string, r *ads.Resource[T], metadata ads.SubscriptionMetadata)
- func (c ChanSubscriptionHandler[T]) WaitForDelete(t testingT, expectedName string) Notification[T]
- func (c ChanSubscriptionHandler[T]) WaitForNotifications(t testingT, notifications ...ExpectedNotification[T]) (out []Notification[T])
- func (c ChanSubscriptionHandler[T]) WaitForUpdate(t testingT, r *ads.Resource[T]) Notification[T]
- type ExpectedNotification
- type FuncHandler
- type Notification
- type RawFuncHandler
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTimeout ¶
func MustMarshal ¶
func ProtoEquals ¶
func ResourceEquals ¶
Types ¶
type ChanSubscriptionHandler ¶
type ChanSubscriptionHandler[T proto.Message] chan Notification[T]
func (ChanSubscriptionHandler[T]) Notify ¶
func (c ChanSubscriptionHandler[T]) Notify(name string, r *ads.Resource[T], metadata ads.SubscriptionMetadata)
func (ChanSubscriptionHandler[T]) WaitForDelete ¶
func (c ChanSubscriptionHandler[T]) WaitForDelete( t testingT, expectedName string, ) Notification[T]
func (ChanSubscriptionHandler[T]) WaitForNotifications ¶
func (c ChanSubscriptionHandler[T]) WaitForNotifications(t testingT, notifications ...ExpectedNotification[T]) (out []Notification[T])
func (ChanSubscriptionHandler[T]) WaitForUpdate ¶
func (c ChanSubscriptionHandler[T]) WaitForUpdate(t testingT, r *ads.Resource[T]) Notification[T]
type ExpectedNotification ¶
func ExpectDelete ¶
func ExpectDelete[T proto.Message](name string) ExpectedNotification[T]
func ExpectUpdate ¶
func ExpectUpdate[T proto.Message](r *ads.Resource[T]) ExpectedNotification[T]
type FuncHandler ¶
FuncHandler is a SubscriptionHandler implementation that simply invokes a function. Note that the usual pattern of having a literal func type implement the interface (e.g. http.HandlerFunc) does not work in this case because funcs are not hashable and therefore cannot be used as map keys, which is often how SubscriptionHandlers are used.
func NewSubscriptionHandler ¶
func NewSubscriptionHandler[T proto.Message]( notify func(name string, r *ads.Resource[T], metadata ads.SubscriptionMetadata), ) *FuncHandler[T]
NewSubscriptionHandler returns a SubscriptionHandler that invokes the given function when SubscriptionHandler.Notify is invoked.
func (*FuncHandler[T]) Notify ¶
func (f *FuncHandler[T]) Notify(name string, r *ads.Resource[T], metadata ads.SubscriptionMetadata)
type Notification ¶
type RawFuncHandler ¶
type RawFuncHandler struct {
// contains filtered or unexported fields
}
func NewRawSubscriptionHandler ¶
func NewRawSubscriptionHandler( t testingT, notify func(name string, r *ads.RawResource, metadata ads.SubscriptionMetadata), ) *RawFuncHandler
NewRawSubscriptionHandler returns a RawSubscriptionHandler that invokes the given function when SubscriptionHandler.Notify is invoked.
func (*RawFuncHandler) Notify ¶
func (r *RawFuncHandler) Notify(name string, raw *ads.RawResource, metadata ads.SubscriptionMetadata)
func (*RawFuncHandler) ResourceMarshalError ¶
func (r *RawFuncHandler) ResourceMarshalError(name string, resource proto.Message, err error)
type TestServer ¶
TestServer is instantiated with NewTestGRPCServer and serves to facilitate local testing against gRPC service implementations.
func NewTestGRPCServer ¶
func NewTestGRPCServer(t *testing.T, opts ...grpc.ServerOption) *TestServer
NewTestGRPCServer is a utility function that spins up a TCP listener on a random local port along with a grpc.Server. It cleans up any associated state using the Cleanup methods. Sample usage is as follows:
ts := NewTestGRPCServer(t) discovery.RegisterAggregatedDiscoveryServiceServer(ts.Server, s) ts.Start() conn := ts.Dial()
func (*TestServer) AddrString ¶
func (ts *TestServer) AddrString() string
func (*TestServer) Dial ¶
func (ts *TestServer) Dial(opts ...grpc.DialOption) *grpc.ClientConn
Dial invokes DialContext with the given options and a context generated using Context.
func (*TestServer) Start ¶
func (ts *TestServer) Start()
Start starts the backing gRPC server in a goroutine. Must be invoked _after_ registering the services.