unittest

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyV3Chart

func CopyV3Chart(chartRoute, currentRoute string, templatesToAssert []string, targetChart *v3chart.Chart) *v3chart.Chart

Copy the V3Chart and its dependencies with partials and optional selected test files.

Types

type Assertion

type Assertion struct {
	Template         string
	DocumentIndex    int
	DocumentSelector *valueutils.DocumentSelector
	Not              bool
	AssertType       string
	// contains filtered or unexported fields
}

Assertion defines target and metrics to validate rendered result

func (*Assertion) Assert

func (a *Assertion) Assert(
	templatesResult map[string][]common.K8sManifest,
	snapshotComparer validators.SnapshotComparer,
	renderSucceed bool,
	renderError error,
	result *results.AssertionResult,
) *results.AssertionResult

Assert validate the rendered manifests with validator

func (*Assertion) UnmarshalYAML

func (a *Assertion) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implement yaml.Unmalshaler, construct validator according to the assert type

type KubernetesFakeClientProvider added in v0.5.0

type KubernetesFakeClientProvider struct {
	Scheme  map[string]KubernetesFakeKindProps `yaml:"scheme"`
	Objects []map[string]interface{}           `yaml:"objects"`
}

func (*KubernetesFakeClientProvider) GetClientFor added in v0.5.0

type KubernetesFakeKindProps added in v0.5.0

type KubernetesFakeKindProps struct {
	ShouldErr  error                       `yaml:"should_err"`
	Gvr        schema.GroupVersionResource `yaml:"gvr"`
	Namespaced bool                        `yaml:"namespaced"`
}

type TestJob

type TestJob struct {
	Name             string `yaml:"it"`
	Values           []string
	Set              map[string]interface{}
	Template         string
	Templates        []string
	DocumentIndex    *int                         `yaml:"documentIndex"`
	DocumentSelector *valueutils.DocumentSelector `yaml:"documentSelector"`
	Release          struct {
		Name      string
		Namespace string
		Revision  int
		IsUpgrade bool `yaml:"upgrade"`
	}
	Chart struct {
		Version    string
		AppVersion string `yaml:"appVersion"`
	}
	Capabilities struct {
		MajorVersion string   `yaml:"majorVersion"`
		MinorVersion string   `yaml:"minorVersion"`
		APIVersions  []string `yaml:"apiVersions"`
	}
	Assertions         []*Assertion                 `yaml:"asserts"`
	KubernetesProvider KubernetesFakeClientProvider `yaml:"kubernetesProvider"`
	// contains filtered or unexported fields
}

TestJob definition of a test, including values and assertions

func (*TestJob) RunV3

func (t *TestJob) RunV3(
	targetChart *v3chart.Chart,
	cache *snapshot.Cache,
	failfast bool,
	renderPath string,
	result *results.TestJobResult,
) *results.TestJobResult

RunV3 render the chart and validate it with assertions in TestJob.

type TestRunner

type TestRunner struct {
	Printer        *printer.Printer
	Formatter      formatter.Formatter
	UpdateSnapshot bool
	WithSubChart   bool
	Strict         bool
	Failfast       bool
	TestFiles      []string
	ChartTestsPath string
	ValuesFiles    []string
	OutputFile     string
	RenderPath     string
	// contains filtered or unexported fields
}

TestRunner stores basic settings and testing status for running all tests

func (*TestRunner) RunV3

func (tr *TestRunner) RunV3(ChartPaths []string) bool

RunV3 test suites in chart in ChartPaths.

type TestSuite

type TestSuite struct {
	Name      string `yaml:"suite"`
	Values    []string
	Set       map[string]interface{}
	Templates []string
	Release   struct {
		Name      string
		Namespace string
		Revision  int
		IsUpgrade bool `yaml:"upgrade"`
	}
	Chart struct {
		Version    string
		AppVersion string `yaml:"appVersion"`
	}
	Capabilities struct {
		MajorVersion string   `yaml:"majorVersion"`
		MinorVersion string   `yaml:"minorVersion"`
		APIVersions  []string `yaml:"apiVersions"`
	}
	KubernetesProvider KubernetesFakeClientProvider `yaml:"kubernetesProvider"`
	Tests              []*TestJob

	// An identifier to append to snapshot files
	SnapshotId string `yaml:"snapshotId"`
	// contains filtered or unexported fields
}

TestSuite defines scope and templates to render and tests to run

func ParseTestSuiteFile

func ParseTestSuiteFile(suiteFilePath, chartRoute string, strict bool, valueFilesSet []string) ([]*TestSuite, error)

ParseTestSuiteFile parse a suite file that contain one or more suites at path and returns an array of TestSuite

func RenderTestSuiteFiles added in v0.3.6

func RenderTestSuiteFiles(helmTestSuiteDir string, chartRoute string, strict bool, valueFilesSet []string, renderValues map[string]interface{}) ([]*TestSuite, error)

RenderTestSuiteFiles renders a helm suite of test files and returns their TestSuites

func (*TestSuite) RunV3

func (s *TestSuite) RunV3(
	chartPath string,
	snapshotCache *snapshot.Cache,
	failfast bool,
	renderPath string,
	result *results.TestSuiteResult,
) *results.TestSuiteResult

RunV3 runs all the test jobs defined in TestSuite.

func (*TestSuite) SnapshotFileUrl added in v0.3.6

func (s *TestSuite) SnapshotFileUrl() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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