github.com/argoproj/argo-cd@v1.8.7/test/manifests_test.go (about) 1 package test 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 "testing" 8 9 argoexec "github.com/argoproj/pkg/exec" 10 "github.com/stretchr/testify/assert" 11 12 "github.com/argoproj/argo-cd/test/fixture/test" 13 ) 14 15 func TestKustomizeVersion(t *testing.T) { 16 test.CIOnly(t) 17 out, err := argoexec.RunCommand("kustomize", argoexec.CmdOpts{}, "version") 18 assert.NoError(t, err) 19 assert.Contains(t, out, "Version:kustomize/v3", "kustomize should be version 3") 20 } 21 22 // TestBuildManifests makes sure we are consistent in naming, and all kustomization.yamls are buildable 23 func TestBuildManifests(t *testing.T) { 24 err := filepath.Walk("../manifests", func(path string, f os.FileInfo, err error) error { 25 if err != nil { 26 return err 27 } 28 switch filepath.Base(path) { 29 case "kustomization.yaml": 30 // noop 31 case "Kustomization", "kustomization.yml": 32 // These are valid, but we want to be consistent with filenames 33 return fmt.Errorf("Please name file 'kustomization.yaml' instead of '%s'", filepath.Base(path)) 34 case "Kustomize", "kustomize.yaml", "kustomize.yml": 35 // These are not even valid kustomization filenames but sometimes get mistaken for them 36 return fmt.Errorf("'%s' is not a valid kustomize name", filepath.Base(path)) 37 default: 38 return nil 39 } 40 dirName := filepath.Dir(path) 41 _, err = argoexec.RunCommand("kustomize", argoexec.CmdOpts{}, "build", dirName) 42 return err 43 }) 44 assert.NoError(t, err) 45 }