targettesting

package
v0.0.0-...-0da46e6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromJSON

func FromJSON(data string) func(t *testing.T) interface{}

FromJSON returns a function that will unmarshal the JSON string and handle errors appropriately.

Types

type ReviewTestcase

type ReviewTestcase struct {
	Name                string                         // Name of the testcase
	Match               map[string]interface{}         // Constraint's Match block
	Object              func(t *testing.T) interface{} // function which returns an Object that's getting passed to the Review call
	WantMatch           bool                           // true if the match should succeed
	WantConstraintError bool                           // true if adding the constraint should fail
	WantLogged          *regexp.Regexp                 // regexp to check against logged messages
	// contains filtered or unexported fields
}

ReviewTestcase exercises the TargetHandler's HandleReview and Library matching_constraints functions.

type TargetHandlerTest

type TargetHandlerTest struct {
	// NewTargetHandler returns a new target handler.  This should call t.Helper()
	// and t.Fatal() on any errors encountered during creation.
	NewTargetHandler func(t *testing.T) handler.TargetHandler

	// ReviewTestcases are the testcases that will be run against client.Review.
	ReviewTestcases []*ReviewTestcase
}

TargetHandlerTest is a test harness for target handler

func CreateTargetHandler

func CreateTargetHandler(t *testing.T, target handler.TargetHandler, tcs []*ReviewTestcase) *TargetHandlerTest

func (*TargetHandlerTest) Test

func (tt *TargetHandlerTest) Test(t *testing.T)

Test runs all testcases in the TargetHandlerTest

Jump to

Keyboard shortcuts

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