frameworktestutil

package
v0.10.6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package frameworktestutil contains utilities for testing functions written using the framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResultsChecker

type ResultsChecker struct {
	// TestDataDirectory is the directory containing the testdata subdirectories.
	// ResultsChecker will recurse into each test directory and run the Command
	// if the directory contains both the ConfigInputFilename and at least one
	// of ExpectedOutputFilname or ExpectedErrorFilename.
	// Defaults to "testdata"
	TestDataDirectory string

	// ConfigInputFilename is the name of the config file provided as the first
	// argument to the function.  Directories without this file will be skipped.
	// Defaults to "config.yaml"
	ConfigInputFilename string

	// InputFilenameGlob matches function inputs
	// Defaults to "input*.yaml"
	InputFilenameGlob string

	// ExpectedOutputFilename is the file with the expected output of the function
	// Defaults to "expected.yaml".  Directories containing neither this file
	// nore ExpectedErrorFilename will be skipped.
	ExpectedOutputFilename string

	// ExpectedErrorFilename is the file containing part of an expected error message
	// Defaults to "error.yaml".  Directories containing neither this file
	// nore ExpectedOutputFilname will be skipped.
	ExpectedErrorFilename string

	// Command provides the function to run.
	Command func() *cobra.Command
}

ResultsChecker tests a function by running it with predefined inputs and comparing the outputs to expected results.

func (ResultsChecker) Assert

func (rc ResultsChecker) Assert(t *testing.T) bool

Assert asserts the results for functions

Jump to

Keyboard shortcuts

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