testutil

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CasesDir = "./testdata/declarative"
)

Variables

View Source
var CompareResourceProcs = map[string]func(expected, actual *unstructured.Unstructured) (bool, error){
	"Secret":     secretsAreEqual,
	"ConfigMap":  configMapsAreEqual,
	"Deployment": deploymentsAreEqual,
}

CompareResourceProcs maps object kind's to their associated comparison procedures. To add new comparison procedures, ensure they are added to compareResourceProcs and follow the same signature.

Functions

func CompareResources added in v0.2.0

func CompareResources(uc UtilContext, path string)

CompareResources compares expected resource found locally in path and compares it against the resource found in the k8s cluster accessed via client defined in uc.Opts.

Resource type is inferred dynamically. The resource found in path musth ave a supporting comparison procedure implemented.

See testutil.CompareResourceProcs for supported procedures.

func DeleteResource added in v0.2.0

func DeleteResource(uc UtilContext, path string)

DeleteResource will delete resource found in path by requesting a generic delete request to the client provided via uc.Opts

func DeployResource added in v0.2.0

func DeployResource(uc UtilContext, path string)

DeployResource will deploy resource found in path by requesting a generic apply request to the client provided via uc.Opts

func DirExists added in v0.2.0

func DirExists(path string) (bool, error)

DirExists checks whether dir at path exists

func ResourceDoesNotExists added in v0.2.0

func ResourceDoesNotExists(uc UtilContext, path string)

ResourceDoesNotExists will check against the client provided by uc.Opts whether resource at path exists.

Types

type Case added in v0.2.0

type Case struct {
	Description string
	Config      string
	Deploy      []string
	Expected    Expectation
}

func GenerateDeclarativeTestCases added in v0.2.0

func GenerateDeclarativeTestCases() []Case

GenerateDeclarativeTestCases dynamically generate testcases based on resources located in the testdata directory.

type Expectation added in v0.2.0

type Expectation struct {
	Created    []string
	NotCreated []string
}

type UtilContext added in v0.2.0

type UtilContext struct {
	Ctx    context.Context
	Ns     string
	Opts   mf.Option
	Client client.Client
}

Jump to

Keyboard shortcuts

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