Documentation ¶
Index ¶
- func CliCommand() *cli.Command
- func GetPathPair(fullPath, testSuffix string) (configPath, definitionPath string)
- func GetTestTargets(targetPaths []string, testSuffix string) (map[string][]test.Case, error)
- func OptAddResourcesPaths(paths []string) func(*ProcessorsProvider)
- func OptProcessorsProviderSetLogger(logger log.Modular) func(*ProcessorsProvider)
- func RunAll(paths []string, testSuffix string, lint bool, logger log.Modular, ...) bool
- type CaseFailure
- type ProcProvider
- type ProcessorsProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CliCommand ¶
func CliCommand() *cli.Command
CliCommand is a cli.Command definition for unit testing.
func GetPathPair ¶
GetPathPair returns the config path and expected accompanying test definition path for a given syntax and a path for either file.
func GetTestTargets ¶
GetTestTargets searches for test definition targets in a path with a given test suffix.
func OptAddResourcesPaths ¶
func OptAddResourcesPaths(paths []string) func(*ProcessorsProvider)
OptAddResourcesPaths adds paths to files where resources should be parsed.
func OptProcessorsProviderSetLogger ¶
func OptProcessorsProviderSetLogger(logger log.Modular) func(*ProcessorsProvider)
OptProcessorsProviderSetLogger sets the logger used by tested components.
Types ¶
type CaseFailure ¶
CaseFailure encapsulates information about a failed test case.
func Execute ¶ added in v4.25.0
func Execute(cases []test.Case, testFilePath string, resourcesPaths []string, logger log.Modular) ([]CaseFailure, error)
Execute the test definition.
func ExecuteFrom ¶ added in v4.25.0
func ExecuteFrom(fs fs.FS, dir string, c test.Case, provider ProcProvider) (failures []CaseFailure, err error)
ExecuteFrom executes a test case from the perspective of a given directory, which is used for obtaining relative condition file imports.
func (CaseFailure) String ¶
func (c CaseFailure) String() string
String returns a string representation of the case failure.
type ProcProvider ¶
type ProcProvider interface { Provide(jsonPtr string, environment map[string]string, mocks map[string]any) ([]iprocessor.V1, error) ProvideBloblang(path string) ([]iprocessor.V1, error) }
ProcProvider returns compiled processors extracted from a Benthos config using a JSON Pointer.
type ProcessorsProvider ¶
type ProcessorsProvider struct {
// contains filtered or unexported fields
}
ProcessorsProvider consumes a Benthos config and, given a JSON Pointer, extracts and constructs the target processors from the config file.
func NewProcessorsProvider ¶
func NewProcessorsProvider(targetPath string, opts ...func(*ProcessorsProvider)) *ProcessorsProvider
NewProcessorsProvider returns a new processors provider aimed at a filepath.
func (*ProcessorsProvider) Provide ¶
func (p *ProcessorsProvider) Provide(jsonPtr string, environment map[string]string, mocks map[string]any) ([]processor.V1, error)
Provide attempts to extract an array of processors from a Benthos config. Supports injected mocked components in the parsed config. If the JSON Pointer targets a single processor config it will be constructed and returned as an array of one element.
func (*ProcessorsProvider) ProvideBloblang ¶
func (p *ProcessorsProvider) ProvideBloblang(pathStr string) ([]processor.V1, error)
ProvideBloblang attempts to parse a Bloblang mapping and returns a processor slice that executes it.