|
|
|
@ -30,10 +30,10 @@ var (
|
|
|
|
|
chart2MultipleChartLint = "testdata/charts/multiplecharts-lint-chart-2"
|
|
|
|
|
corruptedTgzChart = "testdata/charts/corrupted-compressed-chart.tgz"
|
|
|
|
|
chartWithNoTemplatesDir = "testdata/charts/chart-with-no-templates-dir"
|
|
|
|
|
messyChartWithLintIgnore = "testdata/charts/messy-chart-with-lintignore"
|
|
|
|
|
messyChartWithLintIgnore = "testdata/charts/messy-chart-with-lintconfig"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const emptyLintIgnoreFilePath = ""
|
|
|
|
|
const emptyLintConfigFilePath = ""
|
|
|
|
|
|
|
|
|
|
var settings = cli.New()
|
|
|
|
|
|
|
|
|
@ -115,7 +115,7 @@ func TestNonExistentChart(t *testing.T) {
|
|
|
|
|
expectedError := "unable to open tarball: open non-existent-chart.tgz: no such file or directory"
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
|
|
|
|
|
result := testLint.Run(testCharts, values, emptyLintIgnoreFilePath, debugLogFn)
|
|
|
|
|
result := testLint.Run(testCharts, values, emptyLintConfigFilePath, debugLogFn)
|
|
|
|
|
if len(result.Errors) != 1 {
|
|
|
|
|
t.Error("expected one error, but got", len(result.Errors))
|
|
|
|
|
}
|
|
|
|
@ -131,7 +131,7 @@ func TestNonExistentChart(t *testing.T) {
|
|
|
|
|
expectedEOFError := "unable to extract tarball: EOF"
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
|
|
|
|
|
result := testLint.Run(testCharts, values, emptyLintIgnoreFilePath, debugLogFn)
|
|
|
|
|
result := testLint.Run(testCharts, values, emptyLintConfigFilePath, debugLogFn)
|
|
|
|
|
if len(result.Errors) != 1 {
|
|
|
|
|
t.Error("expected one error, but got", len(result.Errors))
|
|
|
|
|
}
|
|
|
|
@ -146,7 +146,7 @@ func TestNonExistentChart(t *testing.T) {
|
|
|
|
|
func TestLint_MultipleCharts(t *testing.T) {
|
|
|
|
|
testCharts := []string{chart2MultipleChartLint, chart1MultipleChartLint}
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintIgnoreFilePath, debugLogFn); len(result.Errors) > 0 {
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintConfigFilePath, debugLogFn); len(result.Errors) > 0 {
|
|
|
|
|
t.Error(result.Errors)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -154,7 +154,7 @@ func TestLint_MultipleCharts(t *testing.T) {
|
|
|
|
|
func TestLint_EmptyResultErrors(t *testing.T) {
|
|
|
|
|
testCharts := []string{chart2MultipleChartLint}
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintIgnoreFilePath, debugLogFn); len(result.Errors) > 0 {
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintConfigFilePath, debugLogFn); len(result.Errors) > 0 {
|
|
|
|
|
t.Error("Expected no error, got more")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -164,7 +164,7 @@ func TestLint_ChartWithWarnings(t *testing.T) {
|
|
|
|
|
testCharts := []string{chartWithNoTemplatesDir}
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
testLint.Strict = false
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintIgnoreFilePath, debugLogFn); len(result.Errors) > 0 {
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintConfigFilePath, debugLogFn); len(result.Errors) > 0 {
|
|
|
|
|
t.Error("Expected no error, got more")
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -173,18 +173,18 @@ func TestLint_ChartWithWarnings(t *testing.T) {
|
|
|
|
|
testCharts := []string{chartWithNoTemplatesDir}
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
testLint.Strict = true
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintIgnoreFilePath, debugLogFn); len(result.Errors) != 0 {
|
|
|
|
|
if result := testLint.Run(testCharts, values, emptyLintConfigFilePath, debugLogFn); len(result.Errors) != 0 {
|
|
|
|
|
t.Error("expected no errors, but got", len(result.Errors))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestLint_MessyChartWithLintIgnoreFile(t *testing.T) {
|
|
|
|
|
t.Run("should find no errors or messages using its own .helmlintignore file", func(t *testing.T) {
|
|
|
|
|
func TestLint_MessyChartWithLintConfigFile(t *testing.T) {
|
|
|
|
|
t.Run("should find no errors or messages using its own .helmlintconfig file", func(t *testing.T) {
|
|
|
|
|
testCharts := []string{messyChartWithLintIgnore}
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
testLint.Strict = false
|
|
|
|
|
result := testLint.Run(testCharts, values, emptyLintIgnoreFilePath, debugLogFn)
|
|
|
|
|
result := testLint.Run(testCharts, values, emptyLintConfigFilePath, debugLogFn)
|
|
|
|
|
if len(result.Errors) != 0 {
|
|
|
|
|
t.Error("expected no errors, but got", len(result.Errors))
|
|
|
|
|
}
|
|
|
|
@ -194,11 +194,11 @@ func TestLint_MessyChartWithLintIgnoreFile(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("should find all four errors when we feed it a fake lint ignore file path", func(t *testing.T) {
|
|
|
|
|
fakeLintIgnoreFilePath := "some/file/might/exist/here"
|
|
|
|
|
fakeLintConfigFilePath := "some/file/might/exist/here"
|
|
|
|
|
testCharts := []string{messyChartWithLintIgnore}
|
|
|
|
|
testLint := NewLint()
|
|
|
|
|
testLint.Strict = true
|
|
|
|
|
result := testLint.Run(testCharts, values, fakeLintIgnoreFilePath, debugLogFn)
|
|
|
|
|
result := testLint.Run(testCharts, values, fakeLintConfigFilePath, debugLogFn)
|
|
|
|
|
if len(result.Errors) != 2 {
|
|
|
|
|
t.Error("expected two errors, but got", len(result.Errors))
|
|
|
|
|
}
|
|
|
|
|