Documentation
¶
Overview ¶
Package eventstest provides test helpers for asserting on the events a Recorder posts to its notification webhook.
Sink is an in-process HTTP server that captures the eventv1.Event payloads a Recorder posts to its webhook address. It is the notification endpoint side of the recorder: while the Kubernetes Event sink can be inspected via the apiserver, the webhook payload can only be observed by receiving the HTTP POST.
It is intended for use both by the events module's tests and by controllers that embed the Recorder and want to assert on the events they emit. Point a Recorder at Sink.URL(), emit events, then inspect Events or EventsFor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink is an in-process HTTP server that captures the eventv1.Event payloads a Recorder posts to its webhook address.
Sink is safe for concurrent use.
func NewSink ¶
NewSink starts a Sink and registers its shutdown with t.Cleanup. The caller does not need to call Close explicitly.
func (*Sink) Close ¶
func (s *Sink) Close()
Close shuts down the underlying HTTP server. NewSink already registers this via t.Cleanup; call it directly only when finer control is needed.
func (*Sink) Events ¶
Events returns a snapshot copy of the events received so far, in arrival order.
func (*Sink) EventsFor ¶
EventsFor returns a snapshot copy of the received events whose InvolvedObject matches the given kind, namespace and name, in arrival order.
func (*Sink) SetStatusCode ¶
SetStatusCode sets the HTTP status code the sink returns for every request. It can be called mid-test to change the response. A zero value keeps the default 200.