Documentation
¶
Overview ¶
Package testkit holds the assertions every provider collector is tested against, so that a new provider proves it produces events the core accepts without reimplementing the rules.
The normative specification is roadmap/00-conventions.md section 9.
Index ¶
- func AssertDeterministicIDs(t *testing.T, fn func() string)
- func AssertValidEvent(t *testing.T, raw []byte)
- type EventBuilder
- func (b EventBuilder) Build() event.Event
- func (b EventBuilder) BuildJSON(t *testing.T) []byte
- func (b EventBuilder) BuildStored(receivedAt time.Time) event.Stored
- func (b EventBuilder) WithEventID(id string) EventBuilder
- func (b EventBuilder) WithEventType(eventType string) EventBuilder
- func (b EventBuilder) WithProjectID(id string) EventBuilder
- func (b EventBuilder) WithResourceID(id string) EventBuilder
- func (b EventBuilder) WithSize(size map[string]any) EventBuilder
- func (b EventBuilder) WithState(state string) EventBuilder
- func (b EventBuilder) WithTimestamp(ts time.Time) EventBuilder
- func (b EventBuilder) WithoutSize() EventBuilder
- func (b EventBuilder) WithoutState() EventBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertDeterministicIDs ¶
AssertDeterministicIDs fails the test unless fn returns the same id twice.
func AssertValidEvent ¶
AssertValidEvent fails the test unless raw decodes into an Event that passes every validation rule.
Types ¶
type EventBuilder ¶
type EventBuilder struct {
// contains filtered or unexported fields
}
EventBuilder produces valid events for tests. Every method returns a copy, so a builder can be shared as a base and specialized per case.
func NewEventBuilder ¶
func NewEventBuilder() EventBuilder
NewEventBuilder returns a builder for a valid OpenStack instance create event.
func (EventBuilder) BuildJSON ¶
func (b EventBuilder) BuildJSON(t *testing.T) []byte
BuildJSON returns the event encoded as it travels the wire.
func (EventBuilder) BuildStored ¶
func (b EventBuilder) BuildStored(receivedAt time.Time) event.Stored
BuildStored returns the event paired with a server-side receipt timestamp.
func (EventBuilder) WithEventID ¶
func (b EventBuilder) WithEventID(id string) EventBuilder
WithEventID sets the event id.
func (EventBuilder) WithEventType ¶
func (b EventBuilder) WithEventType(eventType string) EventBuilder
WithEventType sets the event type, which also decides the event's category.
func (EventBuilder) WithProjectID ¶
func (b EventBuilder) WithProjectID(id string) EventBuilder
WithProjectID sets the owning project at or after this event.
func (EventBuilder) WithResourceID ¶
func (b EventBuilder) WithResourceID(id string) EventBuilder
WithResourceID sets the resource id.
func (EventBuilder) WithSize ¶
func (b EventBuilder) WithSize(size map[string]any) EventBuilder
WithSize sets the payload size object.
func (EventBuilder) WithState ¶
func (b EventBuilder) WithState(state string) EventBuilder
WithState sets the payload state.
func (EventBuilder) WithTimestamp ¶
func (b EventBuilder) WithTimestamp(ts time.Time) EventBuilder
WithTimestamp sets the event timestamp.
func (EventBuilder) WithoutSize ¶
func (b EventBuilder) WithoutSize() EventBuilder
WithoutSize clears the payload size, which is how an event says the size did not change.
func (EventBuilder) WithoutState ¶
func (b EventBuilder) WithoutState() EventBuilder
WithoutState clears the payload state, which is how an event says the state did not change.