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