plugintest

package
v0.0.0-...-5428336 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

plugintest provides utilities for black-box testing of protoc.Plugin implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cases

func Cases(t *testing.T, subject protoc.Plugin, cases map[string]Case)

Cases is a utility function that runs a mapping of test cases.

func WithConfiguration

func WithConfiguration(options ...PluginConfigurationOption) *protoc.PluginConfiguration

WithConfiguration creates a new PluginConfiguration and applies all the given options.

func WithDirectives

func WithDirectives(items ...string) (d []rule.Directive)

WithDirectives assigns rule Directives.

Types

type Case

type Case struct {
	// The base name of the proto file to mock parse.  If not set, defaults to 'test' ('test.proto')
	Basename string
	// The relative package path
	Rel string
	// The configuration Name
	PluginName string
	// Optional directives for the package config
	Directives []rule.Directive
	// The input proto file source.  "syntax = proto3" will be automatically prepended.
	Input string
	// The expected value for the final configuration state
	Configuration *protoc.PluginConfiguration
	// Whether to perform integration test portion of the test
	SkipIntegration bool
}

Case holds the inputs and expected outputs for black-box testing of a plugin implementation.

func (*Case) Run

func (tc *Case) Run(t *testing.T, subject protoc.Plugin)

func (*Case) RunIntegration

func (tc *Case) RunIntegration(t *testing.T, subject protoc.Plugin, got *protoc.PluginConfiguration, filename, in string)

type PluginConfigurationOption

type PluginConfigurationOption func(c *protoc.PluginConfiguration)

PluginConfigurationOption modifies a configuration in-place

func WithLabel

func WithLabel(t *testing.T, raw string) PluginConfigurationOption

WithLabel assigns the Label field.

func WithOptions

func WithOptions(options ...string) PluginConfigurationOption

WithOptions assigns the Options field.

func WithOut

func WithOut(out string) PluginConfigurationOption

WithOut assigns the Out field.

func WithOutputs

func WithOutputs(outputs ...string) PluginConfigurationOption

WithOutputs assigns the Outputs field.

Jump to

Keyboard shortcuts

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