testutils

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	// Protoc specifies the path to the `protoc` executable. If empty, the Loader
	// attempts to execute protoc via PATH.
	Protoc string

	// ImportPaths includes any extra -I (or --proto_path) flags to the protoc
	// execution required to resolve all proto dependencies.
	ImportPaths []string

	// BiDirectional specifies whether or not the AST should be resolved with
	// bidirectional AST resolution.
	BiDirectional bool

	// FS overrides the file system used by the Loader. FS must be nil or an
	// instance of *afero.OsFs if LoadProtos is called.
	FS afero.Fs
}

Loader is a testing utility that can resolve an AST in a variety of manners. The loader can be used to provide entities to test functions.

func (Loader) LoadFDSet

func (l Loader) LoadFDSet(t T, path string) (ast pgs.AST)

LoadFDSet resolves an AST from a serialized FileDescriptorSet file path on l.FS. The test/benchmark is fatally stopped if there is any error.

func (Loader) LoadFDSetReader

func (l Loader) LoadFDSetReader(t T, r io.Reader) (ast pgs.AST)

LoadFDSetReader resolve an AST from a serialized FileDescriptorSet in r. The test/benchmark is fatally stopped if there is any error.

func (Loader) LoadProtos

func (l Loader) LoadProtos(t T, files ...string) (ast pgs.AST)

LoadProtos executes protoc against the provided files (or globs, as defined by filepath.Glob), returning a resolved pgs.AST. The test/benchmark is fatally stopped if there is any error.

This function requires the Loader's FS field to be nil or an instance of *afero.OsFs, otherwise, t will be immediately failed.

type T

type T interface {
	Logf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

The T interface represents a reduced API of the testing.T and testing.B standard library types used by the Loader.

Jump to

Keyboard shortcuts

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