|
|
|
@ -32,14 +32,14 @@ import (
|
|
|
|
|
const templateTestBasedir = "./testdata/albatross"
|
|
|
|
|
|
|
|
|
|
func TestValidateAllowedExtension(t *testing.T) {
|
|
|
|
|
var failTest = []string{"/foo", "/test.toml", "regular.json"}
|
|
|
|
|
var failTest = []string{"/foo", "/test.toml"}
|
|
|
|
|
for _, test := range failTest {
|
|
|
|
|
err := validateAllowedExtension(test)
|
|
|
|
|
if err == nil || !strings.Contains(err.Error(), "Valid extensions are .yaml, .yml, .tpl, or .txt") {
|
|
|
|
|
t.Errorf("validateAllowedExtension('%s') to return \"Valid extensions are .yaml, .yml, .tpl, or .txt\", got no error", test)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var successTest = []string{"/foo.yaml", "foo.yaml", "foo.tpl", "/foo/bar/baz.yaml", "NOTES.txt", "_envoy.json"}
|
|
|
|
|
var successTest = []string{"/foo.yaml", "foo.yaml", "foo.tpl", "/foo/bar/baz.yaml", "NOTES.txt"}
|
|
|
|
|
for _, test := range successTest {
|
|
|
|
|
err := validateAllowedExtension(test)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -401,6 +401,7 @@ func TestEmptyWithCommentsManifests(t *testing.T) {
|
|
|
|
|
t.Fatalf("Expected 0 lint errors, got %d", l)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestValidateListAnnotations(t *testing.T) {
|
|
|
|
|
md := &k8sYamlStruct{
|
|
|
|
|
APIVersion: "v1",
|
|
|
|
@ -439,3 +440,35 @@ items:
|
|
|
|
|
t.Fatalf("List objects keep annotations should pass. got: %s", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIsHelperFile(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
fileName string
|
|
|
|
|
expected bool
|
|
|
|
|
}{
|
|
|
|
|
// Should return true (helper files, non-yaml/yml)
|
|
|
|
|
{"_helpers.go", true},
|
|
|
|
|
{"_helpers.json", true},
|
|
|
|
|
{"subdir/_helpers.json", true},
|
|
|
|
|
{"subdir/_partial.tpl", true},
|
|
|
|
|
{"_config.txt", true},
|
|
|
|
|
|
|
|
|
|
// Should return false (yaml/yml files, even with _)
|
|
|
|
|
{"_helpers.yaml", false},
|
|
|
|
|
{"_config.yml", false},
|
|
|
|
|
{"subdir/_partial.yaml", false},
|
|
|
|
|
|
|
|
|
|
// Should return false (regular files without _)
|
|
|
|
|
{"helpers.go", false},
|
|
|
|
|
{"config.json", false},
|
|
|
|
|
{"deployment.yaml", false},
|
|
|
|
|
}
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.fileName, func(t *testing.T) {
|
|
|
|
|
result := isHelperFile(tt.fileName)
|
|
|
|
|
if result != tt.expected {
|
|
|
|
|
t.Errorf("isHelperFile(%q) = %v, expected %v", tt.fileName, result, tt.expected)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|