test

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 14 Imported by: 40

Documentation

Overview

Package test has utilities (asserts, mocks, ...) to use cloudevents in your tests

Package test contains test data and generic tests for testing bindings.

Index

Constants

This section is empty.

Variables

View Source
var (
	Source    = types.URIRef{URL: url.URL{Scheme: "http", Host: "example.com", Path: "/source"}}
	Timestamp = types.Timestamp{Time: time.Date(2020, 03, 21, 12, 34, 56, 780000000, time.UTC)}
	Schema    = types.URI{URL: url.URL{Scheme: "http", Host: "example.com", Path: "/schema"}}
)

Functions

func AllVersions

func AllVersions(events []event.Event) []event.Event

AllVersions returns all versions of each event in events. ID gets a -number suffix so IDs are unique.

func AssertEventContextEquals

func AssertEventContextEquals(t testing.TB, want event.EventContext, have event.EventContext)

AssertEventContextEquals asserts that two event.Event contexts are equals

func AssertEventEquals

func AssertEventEquals(t testing.TB, want event.Event, have event.Event)

AssertEventEquals asserts that two event.Event are equals

func ConvertEventExtensionsToString

func ConvertEventExtensionsToString(t testing.TB, e event.Event) event.Event

ConvertEventExtensionsToString returns a copy of the event.Event where all extensions are converted to strings. Fails the test if conversion fails

func EachEvent

func EachEvent(t *testing.T, events []event.Event, f func(*testing.T, event.Event))

EachEvent runs f as a test for each event in events

func EachMessage

func EachMessage(t *testing.T, messages []binding.Message, f func(*testing.T, binding.Message))

EachMessage runs f as a test for each message in messages

func Events

func Events() []event.Event

Events is a set of test events that should be handled correctly by all event-processing code.

func FullEvent

func FullEvent() event.Event

FullEvent has all context attributes set and JSON string data.

func MinEvent

func MinEvent() event.Event

MinEvent has only required attributes set.

func MustJSON

func MustJSON(t testing.TB, e event.Event) []byte

MustJSON marshals the event.Event to JSON structured representation or panics

func MustToEvent

func MustToEvent(t testing.TB, ctx context.Context, m binding.Message) event.Event

MustToEvent converts a Message to event.Event

func TestNameOf

func TestNameOf(x interface{}) string

TestNameOf generates a string test name from x, esp. for ce.Event and ce.Message.

func WithoutExtensions

func WithoutExtensions(events []event.Event) []event.Event

WithoutExtensions returns a copy of events with no Extensions. Use for testing where extensions are not supported.

Types

This section is empty.

Jump to

Keyboard shortcuts

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