testing

package
v0.0.0-...-08e4202 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 10 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
	// contains filtered or unexported fields
}

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

func (*ReviewTestcase) Run

func (tc *ReviewTestcase) Run(t *testing.T)

Run will set up the client with the TargetHandler and a test constraint template and constraint then run review.

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) client.TargetHandler

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

TargetHandlerTest is a test harness for target handler

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