package testutils

import "github.com/lyft/protoc-gen-star/testutils"

Index

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.

Source Files

loader.go

Version
v0.6.2 (latest)
Published
Dec 13, 2022
Platform
js/wasm
Imports
8 packages
Last checked
5 days ago

Tools for package owners.