Documentation ¶
Index ¶
- Constants
- Variables
- func AssertChartPathExists(t *testing.T, path string) (string, bool)
- func AssertHelmTemplate(t *testing.T, chart string, outDir, valuesDir string) (string, []string, error)
- func AssertTextFileContentEqual(t *testing.T, expectedFile, actualFile, testName string)
- func CopyFile(src, dst string) (err error)
- func FileExists(path string) (bool, error)
- func RunTests(t *testing.T, chart string, testDir string) (*UnitTester, []*TestCase)
- type TestCase
- type UnitTester
Constants ¶
const ( // DefaultDirWritePermissions for directories DefaultDirWritePermissions = 0760 // DefaultFileWritePermissions default permissions when creating a file DefaultFileWritePermissions = 0644 )
Variables ¶
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 ¶
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 ¶
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
credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04
func FileExists ¶
FileExists checks if path exists and is a file
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 ¶
AssertYamlExpected asserts that the expectedDir of generated YAML is contained in the actualDir
func (*TestCase) RegenerateExpectedFiles ¶ added in v0.0.3
RegenerateExpectedFiles regenerates the expected files
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