unittest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute execute unittest command

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,
	result *AssertionResult,
) *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 AssertionResult

type AssertionResult struct {
	Index      int
	FailInfo   []string
	Passed     bool
	AssertType string
	Not        bool
	CustomInfo string
}

AssertionResult result return by Assertion.Assert

type Printer

type Printer struct {
	Writer  io.Writer
	Colored *bool
	// contains filtered or unexported fields
}

Printer simple printing implement

func NewPrinter

func NewPrinter(writer io.Writer, colored *bool) *Printer

NewPrinter create a Printer with Writer to print and colored config

type TestConfig

type TestConfig struct {
	Colored        bool
	UpdateSnapshot bool
	WithSubChart   bool
	TestFiles      []string
}

TestConfig stores config setup by user in command line

type TestJob

type TestJob struct {
	Name       string `yaml:"it"`
	Values     []string
	Set        map[string]interface{}
	Assertions []*Assertion `yaml:"asserts"`
	Release    struct {
		Name      string
		Namespace string
		Revision  int
		IsUpgrade bool
	}
	// contains filtered or unexported fields
}

TestJob defintion of a test, including values and assertions

func (*TestJob) Run

func (t *TestJob) Run(
	targetChart *chart.Chart,
	cache *snapshot.Cache,
	result *TestJobResult,
) *TestJobResult

Run render the chart and validate it with assertions in TestJob

type TestJobResult

type TestJobResult struct {
	DisplayName   string
	Index         int
	Passed        bool
	ExecError     error
	AssertsResult []*AssertionResult
}

TestJobResult result return by TestJob.Run

type TestRunner

type TestRunner struct {
	Printer *Printer
	Config  TestConfig
	// contains filtered or unexported fields
}

TestRunner stores basic settings and testing status for running all tests

func (*TestRunner) Run

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

Run test suites in chart in ChartPaths

type TestSuite

type TestSuite struct {
	Name      string `yaml:"suite"`
	Templates []string
	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) (*TestSuite, error)

ParseTestSuiteFile parse a suite file at path and returns TestSuite

func (*TestSuite) Run

func (s *TestSuite) Run(
	targetChart *chart.Chart,
	snapshotCache *snapshot.Cache,
	result *TestSuiteResult,
) *TestSuiteResult

Run runs all the test jobs defined in TestSuite

type TestSuiteResult

type TestSuiteResult struct {
	DisplayName      string
	FilePath         string
	Passed           bool
	ExecError        error
	TestsResult      []*TestJobResult
	SnapshotCounting struct {
		Total    uint
		Failed   uint
		Created  uint
		Vanished uint
	}
}

TestSuiteResult result return by TestSuite.Run

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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