pkg

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultDirWritePermissions for directories
	DefaultDirWritePermissions = 0760

	// DefaultFileWritePermissions default permissions when creating a file
	DefaultFileWritePermissions = 0644
)

Variables

View Source
var (
	// GenerateExpectedFiles if enabled lets copy the actual files generated over the expected files
	// e.g. if the underlying chart or helm has changed to reset the tests
	GenerateExpectedFiles = flags.NewBoolFlag(false, "HELM_UNIT_REGENERATE_EXPECTED")
)

Functions

func AssertChartPathExists

func AssertChartPathExists(t *testing.T, path string) (string, bool)

AssertChartPath resolves the given path to an absolute file so that it is interpreted as a local file rather than a chart name and asserts the dir exists

func AssertHelmTemplate

func AssertHelmTemplate(t *testing.T, chart string, outDir, valuesDir string) (string, []string, error)

AssertHelmTemplate asserts that we can generate resources for the given chart and folder of values files

func AssertTextFileContentEqual

func AssertTextFileContentEqual(t *testing.T, expectedFile, actualFile, testName string)

AssertTextFileContentEqual asserts that the expected file contents are the same as the actual file contents showing a nice diff if they differ

func CopyFile added in v0.0.3

func CopyFile(src, dst string) (err error)

credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04

func FileExists

func FileExists(path string) (bool, error)

FileExists checks if path exists and is a file

func RunTests

func RunTests(t *testing.T, chart string, testDir string) (*UnitTester, []*TestCase)

RunTests creates a tester for the given chart and test directories and runs the tests

Types

type TestCase

type TestCase struct {
	Chart                string
	Name                 string
	ValuesDir            string
	ExpectedDir          string
	OutDir               string
	ExpectFail           bool
	FailOnExtraResources bool
	// contains filtered or unexported fields
}

TestCase represents an individual test case

func (*TestCase) AssertYamlExpected

func (c *TestCase) AssertYamlExpected(t *testing.T, actualDir string)

AssertYamlExpected asserts that the expectedDir of generated YAML is contained in the actualDir

func (*TestCase) RegenerateExpectedFiles added in v0.0.3

func (c *TestCase) RegenerateExpectedFiles(t *testing.T, actualDir string)

RegenerateExpectedFiles regenerates the expected files

func (*TestCase) Run

func (c *TestCase) Run()

Run runs the unit test

type UnitTester

type UnitTester struct {
	// OutDir the directory charts are generated to
	OutDir string
	// contains filtered or unexported fields
}

UnitTester a unit tester of charts

func NewUnitTester

func NewUnitTester(t *testing.T) (*UnitTester, error)

NewUnitTester creates a new unit tester of charts

func (*UnitTester) LoadTests

func (u *UnitTester) LoadTests(chart string, testDir string) ([]*TestCase, error)

RunTests finds all the tests inside the given testDir and runs the test for each one

func (*UnitTester) RunTests

func (u *UnitTester) RunTests(tests []*TestCase)

RunTests finds all the tests inside the given testDir and runs the test for each one

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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