Version: v2.32.0+incompatible Latest Latest

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0, BSD-3-Clause, MIT Imports: 6 Imported by: 0



Package testutil contains helpers to test and validate custom Beam Schema coders.



This section is empty.


This section is empty.


This section is empty.


type SchemaCoder

type SchemaCoder struct {

	// CmpOptions to pass into the round trip comparison
	CmpOptions cmp.Options
	// contains filtered or unexported fields

SchemaCoder helps validate custom schema coders.

func (*SchemaCoder) Register

func (v *SchemaCoder) Register(rt reflect.Type, encF, decF interface{})

Register adds additional custom types not under test to both the under test and default schema coders.

func (*SchemaCoder) Validate

func (v *SchemaCoder) Validate(t T, rt reflect.Type, encF, decF, schema interface{}, values interface{})

Validate is a test utility to validate custom schema coders generate beam schema encoded bytes.

Validate accepts the reflect.Type to register, factory functions for encoding and decoding, an anonymous struct type equivalent to the encoded format produced and consumed by the factory produced functions and test values. Test values must be either a struct, pointer to struct, or a slice where each element is a struct or pointer to struct.

TODO(lostluck): Improve documentation. TODO(lostluck): Abstract into a configurable struct, to handle

Validate will register the under test factories and generate an encoder and decoder function. These functions will be re-used for all test values. This emulates coders being re-used for all elements within a bundle.

Validate mutates the SchemaCoderValidator, so the SchemaCoderValidator may not be used more than once.

type T

type T interface {
	Run(string, func(*testing.T)) bool
	Errorf(string, ...interface{})
	Failed() bool

T is an interface to facilitate testing the tester. The methods need to match the one's we're using of *testing.T.

Source Files

Jump to

Keyboard shortcuts

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