|
|
|
@ -30,18 +30,15 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
badChartDir = "testdata/badchartfile"
|
|
|
|
|
goodChartDir = "testdata/goodone"
|
|
|
|
|
badChartDir = "testdata/badchartfile"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
badChartFilePath = filepath.Join(badChartDir, "Chart.yaml")
|
|
|
|
|
goodChartFilePath = filepath.Join(goodChartDir, "Chart.yaml")
|
|
|
|
|
nonExistingChartFilePath = filepath.Join(os.TempDir(), "Chart.yaml")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var badChart, _ = chartutil.LoadChartfile(badChartFilePath)
|
|
|
|
|
var goodChart, _ = chartutil.LoadChartfile(goodChartFilePath)
|
|
|
|
|
|
|
|
|
|
// Validation functions Test
|
|
|
|
|
func TestValidateChartYamlNotDirectory(t *testing.T) {
|
|
|
|
@ -73,24 +70,6 @@ func TestValidateChartName(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestValidateChartNameDirMatch(t *testing.T) {
|
|
|
|
|
err := validateChartNameDirMatch(goodChartDir, goodChart)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Errorf("validateChartNameDirMatch to return no error, gor a linter error")
|
|
|
|
|
}
|
|
|
|
|
// It has not name
|
|
|
|
|
err = validateChartNameDirMatch(badChartDir, badChart)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Errorf("validatechartnamedirmatch to return a linter error, got no error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wrong path
|
|
|
|
|
err = validateChartNameDirMatch(badChartDir, goodChart)
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Errorf("validatechartnamedirmatch to return a linter error, got no error")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestValidateChartVersion(t *testing.T) {
|
|
|
|
|
var failTest = []struct {
|
|
|
|
|
Version string
|
|
|
|
@ -209,36 +188,32 @@ func TestChartfile(t *testing.T) {
|
|
|
|
|
Chartfile(&linter)
|
|
|
|
|
msgs := linter.Messages
|
|
|
|
|
|
|
|
|
|
if len(msgs) != 7 {
|
|
|
|
|
t.Errorf("Expected 7 errors, got %d", len(msgs))
|
|
|
|
|
if len(msgs) != 6 {
|
|
|
|
|
t.Errorf("Expected 6 errors, got %d", len(msgs))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(msgs[0].Err.Error(), "name is required") {
|
|
|
|
|
t.Errorf("Unexpected message 0: %s", msgs[0].Err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(msgs[1].Err.Error(), "directory name (badchartfile) and chart name () must be the same") {
|
|
|
|
|
if !strings.Contains(msgs[1].Err.Error(), "apiVersion is required. The value must be either \"v1\" or \"v2\"") {
|
|
|
|
|
t.Errorf("Unexpected message 1: %s", msgs[1].Err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(msgs[2].Err.Error(), "apiVersion is required. The value must be either \"v1\" or \"v2\"") {
|
|
|
|
|
if !strings.Contains(msgs[2].Err.Error(), "version '0.0.0.0' is not a valid SemVer") {
|
|
|
|
|
t.Errorf("Unexpected message 2: %s", msgs[2].Err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(msgs[3].Err.Error(), "version '0.0.0.0' is not a valid SemVer") {
|
|
|
|
|
if !strings.Contains(msgs[3].Err.Error(), "icon is recommended") {
|
|
|
|
|
t.Errorf("Unexpected message 3: %s", msgs[3].Err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(msgs[4].Err.Error(), "icon is recommended") {
|
|
|
|
|
if !strings.Contains(msgs[4].Err.Error(), "chart type is not valid in apiVersion") {
|
|
|
|
|
t.Errorf("Unexpected message 4: %s", msgs[4].Err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(msgs[5].Err.Error(), "chart type is not valid in apiVersion") {
|
|
|
|
|
if !strings.Contains(msgs[5].Err.Error(), "dependencies are not valid in the Chart file with apiVersion") {
|
|
|
|
|
t.Errorf("Unexpected message 5: %s", msgs[5].Err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !strings.Contains(msgs[6].Err.Error(), "dependencies are not valid in the Chart file with apiVersion") {
|
|
|
|
|
t.Errorf("Unexpected message 6: %s", msgs[6].Err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|