Documentation ¶
Overview ¶
Package test contains test data and generic tests for testing bindings.
Package test provides re-usable functions for binding tests.
Index ¶
- Variables
- func AllVersions(events []ce.Event) []ce.Event
- func AssertEventContextEquals(t *testing.T, want cloudevents.EventContext, have cloudevents.EventContext)
- 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 CopyEventContext(e ce.Event) ce.Event
- 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(ctx context.Context, m binding.Message) (e ce.Event, encoding binding.Encoding)
- func NameOf(x interface{}) string
- func NewMockBinaryMessage(e cloudevents.Event) binding.Message
- func NewMockStructuredMessage(e cloudevents.Event) binding.Message
- func NoExtensions(events []ce.Event) []ce.Event
- func RunTranscoderTests(t *testing.T, ctx context.Context, tests []TranscoderTestArgs)
- func SendReceive(t *testing.T, ctx context.Context, in binding.Message, s binding.Sender, ...)
- type MockBinaryMessage
- func (bm *MockBinaryMessage) Binary(ctx context.Context, b binding.BinaryEncoder) error
- func (bm *MockBinaryMessage) Encoding() binding.Encoding
- func (bm *MockBinaryMessage) End() error
- func (bm *MockBinaryMessage) Finish(error) error
- func (bm *MockBinaryMessage) GetParent() binding.Message
- func (bm *MockBinaryMessage) SetAttribute(attribute spec.Attribute, value interface{}) error
- func (bm *MockBinaryMessage) SetData(data io.Reader) (err error)
- func (bm *MockBinaryMessage) SetExtension(name string, value interface{}) error
- func (bm *MockBinaryMessage) Start(ctx context.Context) error
- func (bm *MockBinaryMessage) Structured(context.Context, binding.StructuredEncoder) error
- type MockStructuredMessage
- func (s *MockStructuredMessage) Binary(context.Context, binding.BinaryEncoder) error
- func (bm *MockStructuredMessage) Encoding() binding.Encoding
- func (s *MockStructuredMessage) Finish(error) error
- func (s *MockStructuredMessage) SetStructuredEvent(ctx context.Context, format format.Format, event io.Reader) (err error)
- func (s *MockStructuredMessage) Structured(ctx context.Context, b binding.StructuredEncoder) error
- type TranscoderTestArgs
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AllVersions ¶
AllVersions returns all versions of each event in events. ID gets a -number suffix so IDs are unique.
func AssertEventContextEquals ¶
func AssertEventContextEquals(t *testing.T, want cloudevents.EventContext, have cloudevents.EventContext)
func AssertEventEquals ¶
func AssertEventEquals(t *testing.T, want cloudevents.Event, have cloudevents.Event)
func BenchmarkSendReceive ¶
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 ¶
func NameOf ¶
func NameOf(x interface{}) string
NameOf generates a string test name from x, esp. for ce.Event and ce.Message.
func NewMockBinaryMessage ¶
func NewMockBinaryMessage(e cloudevents.Event) binding.Message
func NewMockStructuredMessage ¶
func NewMockStructuredMessage(e cloudevents.Event) binding.Message
func NoExtensions ¶
NoExtensions returns a copy of events with no Extensions. Use for testing where extensions are not supported.
func RunTranscoderTests ¶
func RunTranscoderTests(t *testing.T, ctx context.Context, tests []TranscoderTestArgs)
Types ¶
type MockBinaryMessage ¶
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 (*MockBinaryMessage) Binary ¶
func (bm *MockBinaryMessage) Binary(ctx context.Context, b binding.BinaryEncoder) error
func (*MockBinaryMessage) Encoding ¶
func (bm *MockBinaryMessage) Encoding() binding.Encoding
func (*MockBinaryMessage) End ¶
func (bm *MockBinaryMessage) End() error
func (*MockBinaryMessage) Finish ¶
func (bm *MockBinaryMessage) Finish(error) error
func (*MockBinaryMessage) GetParent ¶
func (bm *MockBinaryMessage) GetParent() binding.Message
func (*MockBinaryMessage) SetAttribute ¶
func (bm *MockBinaryMessage) SetAttribute(attribute spec.Attribute, value interface{}) error
func (*MockBinaryMessage) SetData ¶
func (bm *MockBinaryMessage) SetData(data io.Reader) (err error)
func (*MockBinaryMessage) SetExtension ¶
func (bm *MockBinaryMessage) SetExtension(name string, value interface{}) error
func (*MockBinaryMessage) Structured ¶
func (bm *MockBinaryMessage) Structured(context.Context, binding.StructuredEncoder) error
type MockStructuredMessage ¶
MockStructuredMessage implements a structured-mode message as a simple struct.
func (*MockStructuredMessage) Binary ¶
func (s *MockStructuredMessage) Binary(context.Context, binding.BinaryEncoder) error
func (*MockStructuredMessage) Encoding ¶
func (bm *MockStructuredMessage) Encoding() binding.Encoding
func (*MockStructuredMessage) Finish ¶
func (s *MockStructuredMessage) Finish(error) error
func (*MockStructuredMessage) SetStructuredEvent ¶
func (*MockStructuredMessage) Structured ¶
func (s *MockStructuredMessage) Structured(ctx context.Context, b binding.StructuredEncoder) error
type TranscoderTestArgs ¶
type TranscoderTestArgs struct { Name string InputMessage binding.Message WantEvent cloudevents.Event Transformers []binding.TransformerFactory }