Documentation
¶
Overview ¶
Package test contains test data and generic tests for testing bindings.
Package test provides re-usable functions for binding tests.
Index ¶
- func AllVersions(events []ce.Event) []ce.Event
- func AssertEventEquals(t *testing.T, want cloudevents.Event, have cloudevents.Event)
- func BenchmarkSendReceive(b *testing.B, s binding.Sender, r binding.Receiver)
- func Canonical(t *testing.T, c ce.EventContext)
- func EachEvent(t *testing.T, events []ce.Event, f func(*testing.T, ce.Event))
- func EachMessage(t *testing.T, messages []binding.Message, f func(*testing.T, binding.Message))
- func Events() []ce.Event
- func ExToStr(t *testing.T, e ce.Event) ce.Event
- func FullEvent() ce.Event
- func MinEvent() ce.Event
- func MustJSON(e ce.Event) []byte
- func MustToEvent(m binding.Message) (e ce.Event, wasStructured bool, wasBinary bool)
- func NameOf(x interface{}) string
- func NoExtensions(events []ce.Event) []ce.Event
- func SendReceive(t *testing.T, in binding.Message, s binding.Sender, r binding.Receiver, ...)
- type MockBinaryMessage
- type MockStructuredMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllVersions ¶
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
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 EachMessage ¶
Run f as a test for each message in messages
func Events ¶
Events is a set of test events that should be handled correctly by all event-processing code.
func MustToEvent ¶ added in v0.11.0
func NameOf ¶
func NameOf(x interface{}) string
NameOf generates a string test name from x, esp. for ce.Event and ce.Message.
func NoExtensions ¶
NoExtensions returns a copy of events with no Extensions. Use for testing where extensions are not supported.
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 (bm *MockBinaryMessage) Binary(b binding.BinaryEncoder) error
func (*MockBinaryMessage) Event ¶ added in v1.0.0
func (bm *MockBinaryMessage) Event(b binding.EventEncoder) error
func (*MockBinaryMessage) Finish ¶ added in v1.0.0
func (bm *MockBinaryMessage) Finish(error) error
func (*MockBinaryMessage) Structured ¶ added in v1.0.0
func (bm *MockBinaryMessage) Structured(b binding.StructuredEncoder) error
type MockStructuredMessage ¶ added in v1.0.0
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 (s *MockStructuredMessage) Binary(binding.BinaryEncoder) error
func (*MockStructuredMessage) Event ¶ added in v1.0.0
func (s *MockStructuredMessage) Event(b binding.EventEncoder) error
func (*MockStructuredMessage) Finish ¶ added in v1.0.0
func (s *MockStructuredMessage) Finish(error) error
func (*MockStructuredMessage) Structured ¶ added in v1.0.0
func (s *MockStructuredMessage) Structured(b binding.StructuredEncoder) error