testing

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSupplyChainStringParams added in v0.7.4

func BuildSupplyChainStringParams(candidateParams []StringParam) ([]v1alpha1.BlueprintParam, error)

BuildSupplyChainStringParams is a helper method for creating string SupplyChainParams. SupplyChainParams that hold other valid JSON values must be constructed by hand.

func CliTest added in v0.7.4

func CliTest(directory string) error

func Cmd

func Cmd(argv ...string) *cmd

func ConvertNumbersToFloatsDuringComparison added in v0.7.4

func ConvertNumbersToFloatsDuringComparison() (cmp.Options, error)

func Execute

func Execute()

func YTT

func YTT() *ytt

Types

type CMPOption added in v0.7.4

type CMPOption func() (cmp.Options, error)

type CompareOptions added in v0.7.4

type CompareOptions struct {
	IgnoreMetadata       bool
	IgnoreOwnerRefs      bool
	IgnoreLabels         bool
	IgnoreMetadataFields []string
	CMPOption            CMPOption
}

type Expectation added in v0.7.4

type Expectation interface {
	// contains filtered or unexported methods
}

type ExpectedFile added in v0.7.4

type ExpectedFile struct {
	Path string
}

type ExpectedObject added in v0.7.4

type ExpectedObject struct {
	Object client.Object
}

type ExpectedUnstructured added in v0.7.4

type ExpectedUnstructured struct {
	Unstructured *unstructured.Unstructured
}

type FailedTest

type FailedTest struct {
	// contains filtered or unexported fields
}

type Given added in v0.7.4

type Given struct {
	Template    Template
	Workload    Workload
	SupplyChain SupplyChain
}

Given must specify a Template and a Workload. SupplyChain is optional

type Inputs added in v0.6.0

type Inputs struct {
	Sources    map[string]templates.SourceInput
	Images     map[string]templates.ImageInput
	Configs    map[string]templates.ConfigInput
	Deployment *templates.SourceInput
}

type MockSupplyChain added in v0.7.4

type MockSupplyChain struct {
	Params SupplyChainParams
	Inputs SupplyChainInputs
}

MockSupplyChain implements SupplyChain SupplyChainInputs simulate expected inputs that are the outputs from earlier resources in the supply chain SupplyChainParams supplies params as if defined in the supply chain

type NoLog added in v0.7.4

type NoLog struct{}

func (*NoLog) Enabled added in v0.7.4

func (n *NoLog) Enabled(_ int) bool

func (*NoLog) Error added in v0.7.4

func (n *NoLog) Error(_ error, _ string, _ ...interface{})

func (*NoLog) Info added in v0.7.4

func (n *NoLog) Info(_ int, _ string, _ ...interface{})

func (*NoLog) Init added in v0.7.4

func (n *NoLog) Init(_ logr.RuntimeInfo)

func (*NoLog) WithName added in v0.7.4

func (n *NoLog) WithName(name string) logr.LogSink

func (*NoLog) WithValues added in v0.7.4

func (n *NoLog) WithValues(_ ...interface{}) logr.LogSink

type StringParam

type StringParam struct {
	Name         string
	Value        string
	DefaultValue string
}

StringParam is a helper struct for use with the BuildSupplyChainStringParams method Either a Value or a DefaultValue should be specified for every StringParam A Name is required for every StringParam

type Suite added in v0.7.4

type Suite map[string]*Test

Suite is a collection of named template tests which may be run together

func (*Suite) Assert added in v0.7.4

func (s *Suite) Assert() ([]string, []*FailedTest)

Assert allows testing a Suite when a *testing.T is not available, e.g. when tests are not run from 'go test' It returns a list of the named tests that passed and a list of the named tests that failed with their errors

func (*Suite) HasFocusedTests added in v0.7.4

func (s *Suite) HasFocusedTests() bool

func (*Suite) Run added in v0.7.4

func (s *Suite) Run(t *testing.T)

func (*Suite) RunConcurrently added in v0.7.4

func (s *Suite) RunConcurrently(t *testing.T)

type SupplyChain added in v0.7.4

type SupplyChain interface {
	// contains filtered or unexported methods
}

type SupplyChainFileSet added in v0.7.4

type SupplyChainFileSet struct {
	Paths              []string
	YttValues          Values
	YttFiles           []string
	TargetResourceName string
	PreviousOutputs    *realizer.Outputs
}

SupplyChainFileSet is a set of one or more supply chains Paths is a list of either paths to a supply chain or a directory containing supply chain files YttValues and YttFiles are values to use in preprocessing the supply chains TargetResourceName is the name of the resource/step that will be stamped PreviousOutputs are mocked outputs from earlier resources/steps in the supply chain

type SupplyChainInputs added in v0.7.4

type SupplyChainInputs interface {
	GetInputs() (*Inputs, error)
}

type SupplyChainInputsFile added in v0.7.4

type SupplyChainInputsFile struct {
	Path string
}

func (*SupplyChainInputsFile) GetInputs added in v0.7.4

func (p *SupplyChainInputsFile) GetInputs() (*Inputs, error)

type SupplyChainInputsObject added in v0.7.4

type SupplyChainInputsObject struct {
	Inputs *Inputs
}

func (*SupplyChainInputsObject) GetInputs added in v0.7.4

func (i *SupplyChainInputsObject) GetInputs() (*Inputs, error)

type SupplyChainParams added in v0.7.4

type SupplyChainParams interface {
	GetParams() ([]v1alpha1.BlueprintParam, error)
}

type SupplyChainParamsFile added in v0.7.4

type SupplyChainParamsFile struct {
	Path string
}

func (*SupplyChainParamsFile) GetParams added in v0.7.4

func (p *SupplyChainParamsFile) GetParams() ([]v1alpha1.BlueprintParam, error)

type SupplyChainParamsObject added in v0.7.4

type SupplyChainParamsObject struct {
	Params []v1alpha1.BlueprintParam
}

func (*SupplyChainParamsObject) GetParams added in v0.7.4

type Template added in v0.7.4

type Template interface {
	GetTemplate() (*ValidatableTemplate, error)
}

type TemplateFile added in v0.7.4

type TemplateFile struct {
	Path      string
	YttValues Values
	YttFiles  []string
}

TemplateFile implements Template Path is the filepath to the yaml template definition. This file may be pre-processed with ytt and including values provided as objects (YttValues) or in yaml files (YttFiles).

func (*TemplateFile) GetTemplate added in v0.7.4

func (i *TemplateFile) GetTemplate() (*ValidatableTemplate, error)

type TemplateObject added in v0.7.4

type TemplateObject struct {
	Template ValidatableTemplate
}

TemplateObject implements Template

func (*TemplateObject) GetTemplate added in v0.7.4

func (t *TemplateObject) GetTemplate() (*ValidatableTemplate, error)

type Test added in v0.7.4

type Test struct {
	Given          Given
	Expect         Expectation
	CompareOptions *CompareOptions
	Focus          bool
}

Test is an individual template test. Given and Expect values must be provided. Fields in the expected object's metadata may be ignored When run as part of a Suite, an individual case(s) may be focused. This will exercise the individual test(s). Note that the overall suite will fail (preventing focused tests from passing CI).

func (*Test) Run added in v0.7.4

func (c *Test) Run() error

type TestFailError

type TestFailError struct {
	// contains filtered or unexported fields
}

func (TestFailError) Error

func (t TestFailError) Error() string

type ValidatableTemplate added in v0.7.4

type ValidatableTemplate interface {
	ValidateCreate() error
	client.Object
}

type Values

type Values map[string]interface{}

func (Values) Encode

func (v Values) Encode(w io.Writer) error

func (Values) Set

func (v Values) Set(kvk string, kvv interface{})

type Workload added in v0.7.4

type Workload interface {
	GetWorkload() (*v1alpha1.Workload, error)
}

type WorkloadFile added in v0.7.4

type WorkloadFile struct {
	Path string
}

func (*WorkloadFile) GetWorkload added in v0.7.4

func (w *WorkloadFile) GetWorkload() (*v1alpha1.Workload, error)

type WorkloadObject added in v0.7.4

type WorkloadObject struct {
	Workload *v1alpha1.Workload
}

func (*WorkloadObject) GetWorkload added in v0.7.4

func (w *WorkloadObject) GetWorkload() (*v1alpha1.Workload, error)

Jump to

Keyboard shortcuts

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