testkit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDeterministicIDs

func AssertDeterministicIDs(t *testing.T, fn func() string)

AssertDeterministicIDs fails the test unless fn returns the same id twice.

func AssertValidEvent

func AssertValidEvent(t *testing.T, raw []byte)

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) Build

func (b EventBuilder) Build() event.Event

Build returns the 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.

Jump to

Keyboard shortcuts

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