test

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

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

Package test provides re-usable functions for binding tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllVersions

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

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

func AssertEventEquals added in v0.11.0

func AssertEventEquals(t *testing.T, want cloudevents.Event, have cloudevents.Event)

func BenchmarkSendReceive added in v0.10.1

func BenchmarkSendReceive(b *testing.B, s binding.Sender, r binding.Receiver)

Simple send/receive benchmark. Requires a sender and receiver that are connected to each other.

func Canonical

func Canonical(t *testing.T, c ce.EventContext)

Canonical converts all attributes to canonical string form for comparisons.

func EachEvent

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

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

Run f as a test for each message in messages

func Events

func Events() []ce.Event

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

func ExToStr added in v0.11.0

func ExToStr(t *testing.T, e ce.Event) ce.Event

func FullEvent

func FullEvent() ce.Event

FullEvent has all context attributes set and JSON string data.

func MinEvent

func MinEvent() ce.Event

MinEvent has only required attributes set.

func MustJSON

func MustJSON(e ce.Event) []byte

func MustToEvent added in v0.11.0

func MustToEvent(m binding.Message) (e ce.Event, wasStructured bool, wasBinary bool)

func NameOf

func NameOf(x interface{}) string

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

func NoExtensions

func NoExtensions(events []ce.Event) []ce.Event

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

func SendReceive

func SendReceive(t *testing.T, in binding.Message, s binding.Sender, r binding.Receiver, outAssert func(binding.Message))

SendReceive does, s.Send(in) and returns r.Receive(). Halt test on error.

Types

type MockBinaryMessage added in v1.0.0

type MockBinaryMessage struct {
	Metadata   map[spec.Attribute]interface{}
	Extensions map[string]interface{}
	Body       []byte
}

MockBinaryMessage implements a binary-mode message as a simple struct.

func NewMockBinaryMessage added in v1.0.0

func NewMockBinaryMessage(e cloudevents.Event) *MockBinaryMessage

func (*MockBinaryMessage) Binary added in v1.0.0

func (*MockBinaryMessage) Event added in v1.0.0

func (*MockBinaryMessage) Finish added in v1.0.0

func (bm *MockBinaryMessage) Finish(error) error

func (*MockBinaryMessage) Structured added in v1.0.0

type MockStructuredMessage added in v1.0.0

type MockStructuredMessage struct {
	Format format.Format
	Bytes  []byte
}

MockStructuredMessage implements a structured-mode message as a simple struct.

func NewMockStructuredMessage added in v1.0.0

func NewMockStructuredMessage(e cloudevents.Event) *MockStructuredMessage

func (*MockStructuredMessage) Binary added in v1.0.0

func (*MockStructuredMessage) Event added in v1.0.0

func (*MockStructuredMessage) Finish added in v1.0.0

func (s *MockStructuredMessage) Finish(error) error

func (*MockStructuredMessage) Structured added in v1.0.0

Jump to

Keyboard shortcuts

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