templatertesting

package
v0.0.204 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSchemaAnnotations

func AddSchemaAnnotations(t *testing.T, schema *v1alpha1.Schema, dynObjects []runtime.Object) error

AddSchemaAnnotations adds the schema annotation to the external secret Unstructured objects

func AssertValidJSON

func AssertValidJSON(t *testing.T, text, message string)

AssertValidJSON asserts that the given text is valid JSON

func AssertValidXML

func AssertValidXML(t *testing.T, text, message string)

AssertValidXML asserts that the given text is valid XML

Types

type Runner

type Runner struct {
	// TestCases the test cases to run
	TestCases []TestCase

	// SchemaFile the schema file to load for the templates
	SchemaFile string

	// Namespace optional namespace - defaults to 'jx'
	Namespace string

	// Dir the directory used to detect the jx-requirements.yml file if none is supplied on the test case
	Dir string

	// KubeObjects so you can define default secrets
	KubeObjects []runtime.Object
}

Runner runs the test harness

func (*Runner) Run

func (r *Runner) Run(t *testing.T)

Run runs the test cases

type TestCase

type TestCase struct {
	// ObjectName name of the object in the schema
	ObjectName string

	// Property name to render; this name is used to find the template in the schema
	Property string

	// TestName is the name of the test
	TestName string

	// ExpectedFile expected file name to compare the generated results against
	ExpectedFile string

	// Format the text format of the output used to perform additional validation
	Format string

	// Dir the directory used to detect the jx-requirements.yml file if none is supplied
	Dir string

	// Requirements the jx-requirements.yml used to parameterize the template
	Requirements *jxcore.RequirementsConfig

	// VerifyFn performs a custom verify of the generated value
	VerifyFn func(*testing.T, string)
}

TestCase represents a test case

Jump to

Keyboard shortcuts

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