assert

package
v0.0.0-...-96258be Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 21

Documentation

Overview

assert contains the necessary matchers and steps to perform assertions on eventshub contents

Index

Constants

View Source
const (
	EventReceived = eventshub.EventReceived
	EventRejected = eventshub.EventRejected

	EventSent     = eventshub.EventSent
	EventResponse = eventshub.EventResponse
)

Reexport kinds here to simplify the usage

Variables

This section is empty.

Functions

func Any

Matcher that never fails

func HasAdditionalHeader

func HasAdditionalHeader(key, value string) eventshub.EventInfoMatcher

Convert a matcher that checks valid messages to a function that checks EventInfo structures, returning an error for any that don't contain valid events.

func MatchEvent

func MatchEvent(evf ...cetest.EventMatcher) eventshub.EventInfoMatcher

Convert a matcher that checks valid messages to a function that checks EventInfo structures, returning an error for any that don't contain valid events.

func MatchHeartBeatsImageMessage

func MatchHeartBeatsImageMessage(expectedMsg string) cetest.EventMatcher

MatchHeartBeatsImageMessage matches that the data field of the event, in the format of the heartbeats image, contains the following msg field

func MatchKind

MatchKind matches the kind of EventInfo

func MatchOIDCUser

func MatchOIDCUser(username string) eventshub.EventInfoMatcher

MatchOIDCUser matches the OIDC username used for the request

func MatchOIDCUserFromResource

func MatchOIDCUserFromResource(gvr schema.GroupVersionResource, resourceName string) eventshub.EventInfoMatcherCtx

MatchOIDCUserFromResource matches the given resources OIDC identifier

func MatchPeerCertificatesFromSecret

func MatchPeerCertificatesFromSecret(namespace, name string, key string) eventshub.EventInfoMatcherCtx

func MatchStatusCode

func MatchStatusCode(statusCode int) eventshub.EventInfoMatcher

MatchStatusCode matches the status code of EventInfo

func NoError

func NoError() eventshub.EventInfoMatcher

Matcher that fails if there is an error in the EventInfo

Types

type MatchAssertionBuilder

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

func OnStore

func OnStore(name string) MatchAssertionBuilder

OnStore creates an assertion builder starting from the name of the store

func (MatchAssertionBuilder) AtLeast

func (m MatchAssertionBuilder) AtLeast(min int) feature.StepFn

AtLeast builds the assertion feature.StepFn OnStore(store).Match(matchers).AtLeast(min) is equivalent to StoreFromContext(ctx, store).AssertAtLeast(min, matchers)

func (MatchAssertionBuilder) Exact

Exact builds the assertion feature.StepFn OnStore(store).Match(matchers).Exact(n) is equivalent to StoreFromContext(ctx, store).AssertExact(n, matchers)

func (MatchAssertionBuilder) InRange

func (m MatchAssertionBuilder) InRange(min int, max int) feature.StepFn

InRange builds the assertion feature.StepFn OnStore(store).Match(matchers).InRange(min, max) is equivalent to StoreFromContext(ctx, store).AssertInRange(min, max, matchers)

func (MatchAssertionBuilder) Match

Match adds the provided matchers in this builder

func (MatchAssertionBuilder) MatchEvent

MatchEvent is a shortcut for Match(MatchEvent(), OneOf(MatchKind(eventshub.EventReceived), MatchKind(eventshub.EventSent)))

func (MatchAssertionBuilder) MatchPeerCertificatesReceived

func (m MatchAssertionBuilder) MatchPeerCertificatesReceived(matchers ...eventshub.EventInfoMatcherCtx) MatchAssertionBuilder

MatchPeerCertificates adds the provided matchers in this builder

func (MatchAssertionBuilder) MatchReceivedEvent

func (m MatchAssertionBuilder) MatchReceivedEvent(matchers ...cetest.EventMatcher) MatchAssertionBuilder

MatchReceivedEvent is a shortcut for Match(MatchKind(eventshub.EventReceived), MatchEvent(matchers...))

func (MatchAssertionBuilder) MatchRejectedEvent

func (m MatchAssertionBuilder) MatchRejectedEvent(matchers ...cetest.EventMatcher) MatchAssertionBuilder

MatchRejectedEvent is a shortcut for Match(MatchKind(eventshub.EventRejected), MatchEvent(matchers...))

func (MatchAssertionBuilder) MatchResponseEvent

func (m MatchAssertionBuilder) MatchResponseEvent(matchers ...cetest.EventMatcher) MatchAssertionBuilder

MatchResponseEvent is a shortcut for Match(MatchKind(eventshub.EventResponse), MatchEvent(matchers...))

func (MatchAssertionBuilder) MatchSentEvent

func (m MatchAssertionBuilder) MatchSentEvent(matchers ...cetest.EventMatcher) MatchAssertionBuilder

MatchSentEvent is a shortcut for Match(MatchKind(eventshub.EventSent), MatchEvent(matchers...))

func (MatchAssertionBuilder) MatchWithContext

MatchWithContext adds the provided matchers in this builder

func (MatchAssertionBuilder) Not

Not builds the assertion feature.StepFn OnStore(store).Match(matchers).Not() is equivalent to StoreFromContext(ctx, store).AssertNot(matchers)

Jump to

Keyboard shortcuts

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