resourcefixture

package
v1.110.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTestName

func FormatTestName(tc ResourceFixture) string

func GetUniqueResourceConfigId

func GetUniqueResourceConfigId(rc v1alpha1.ResourceConfig) string

returns an id that is unique for each resource config

func RunSpecificTests

func RunSpecificTests(t *testing.T, fixtures []ResourceFixture, testCaseFunc TestCaseFunc)

func RunTests

func RunTests(t *testing.T, shouldRun ShouldRunFunc, testCaseFunc TestCaseFunc)

func ShouldHaveResourceConfig

func ShouldHaveResourceConfig(u *unstructured.Unstructured, serviceMetadataLoader dclmetadata.ServiceMetadataLoader) bool

Types

type HeavyFilter

type HeavyFilter func(fixture ResourceFixture) bool

type LightFilter

type LightFilter func(name string, testType TestType) bool

type ResourceFixture

type ResourceFixture struct {
	GVK          schema.GroupVersionKind
	Name         string
	Create       []byte
	Update       []byte
	Dependencies []byte
	Type         TestType
}

func GetBasicTypeSetCover

func GetBasicTypeSetCover(t *testing.T) []ResourceFixture

func GetFilteredSetCover

func GetFilteredSetCover(t *testing.T, lightFilterFunc LightFilter, heavyFilterFunc HeavyFilter) []ResourceFixture

GetFilteredSetCover is an implementation of https://en.wikipedia.org/wiki/Set_cover_problem#Greedy_algorithm: returns a minimal set cover from the resource fixtures that match the given filters.

The set cover is determined by resource config, that is to say, for every resource config there is at least one resource returned in the set cover. The result of this function is useful when you wish to run a test for every resource type that is supported, but for performance and quota reasons, not across every fixture. For example, when you want to test every resource but don't want to test a given resource more than once. For example, the basic/pubsubsubscription fixture covers both the PubSubTopic and PubSubSubscription resources. There is no reason to also run a test on the basic/pubsubtopic fixture if covering each unique resource is your goal.

func Load

func Load(t *testing.T) []ResourceFixture

Load loads all test cases found in the testdata directory. A test case is any directory in the tree that contains a create.yaml file (and optionally a dependencies.yaml and update.yaml). The name of the directory containing the YAMLs is used as the name of the test case.

func LoadWithFilter

func LoadWithFilter(t *testing.T, lightFilterFunc LightFilter, heavyFilterFunc HeavyFilter) []ResourceFixture

LoadWithFilter returns all fixtures that match the filter functions - a filter function matches by returning 'true' * use 'lightFilterFunc' for filtering based on test names and types (determining these values is 'lightweight' as it only relies on directory and file names) * use 'heavyFilterFunc' for filtering based on the contents of the YAML file(s)

if a 'nil' value is supplied for a given filter function then it is assumed that all fixtures match the filter

type ShouldRunFunc

type ShouldRunFunc func(fixture ResourceFixture) bool

type TestCaseFunc

type TestCaseFunc func(t *testing.T, fixture ResourceFixture)

type TestType

type TestType string
const (
	Unknown                     TestType = "unknown"
	Basic                       TestType = "basic"
	ContainerAnnotations        TestType = "containerannotations"
	Directives                  TestType = "directives"
	ExternalRef                 TestType = "externalref"
	SensitiveField              TestType = "sensitivefield"
	IAMExternalOnlyRef          TestType = "iamexternalonlyref"
	IAMMemberReferences         TestType = "iammemberreferences"
	ResourceID                  TestType = "resourceid"
	StateAbsentInSpec           TestType = "stateabsentinspec"
	ResourceOverrides           TestType = "resourceoverrides"
	ReconcileIntervalAnnotation TestType = "reconcileintervalannotations"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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