unittest

package
v0.0.0-...-f1f82f3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	Template      string
	DocumentIndex int
	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 TestJob

type TestJob struct {
	Name          string `yaml:"it"`
	Values        []string
	Set           map[string]interface{}
	Template      string
	Templates     []string
	DocumentIndex *int         `yaml:"documentIndex"`
	Assertions    []*Assertion `yaml:"asserts"`
	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"`
	}
	// contains filtered or unexported fields
}

TestJob definition of a test, including values and assertions

func (*TestJob) RunV2

func (t *TestJob) RunV2(
	targetChart *v2chart.Chart,
	cache *snapshot.Cache,
	failfast bool,
	result *results.TestJobResult,
) *results.TestJobResult

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

func (*TestJob) RunV3

func (t *TestJob) RunV3(
	targetChart *v3chart.Chart,
	cache *snapshot.Cache,
	failfast bool,
	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
	ValuesFiles    []string
	OutputFile     string
	// contains filtered or unexported fields
}

TestRunner stores basic settings and testing status for running all tests

func (*TestRunner) RunV2

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

RunV2 test suites in chart in ChartPaths.

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
	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"`
	}
	Tests []*TestJob
	// 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 at path and returns TestSuite

func (*TestSuite) RunV2

func (s *TestSuite) RunV2(
	targetChart *v2chart.Chart,
	snapshotCache *snapshot.Cache,
	failfast bool,
	result *results.TestSuiteResult,
) *results.TestSuiteResult

RunV2 runs all the test jobs defined in TestSuite.

func (*TestSuite) RunV3

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

RunV3 runs all the test jobs defined in TestSuite.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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