mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Add accumulateResources error tests for local files (#5225)
* Add accumulateResources error tests for local files. Add tests demonstrating accumulateResources errors when the resource is a local file. Works to address #4807. * Improve readability
This commit is contained in:
@@ -11,19 +11,27 @@ import (
|
||||
"sigs.k8s.io/kustomize/kyaml/filesys"
|
||||
)
|
||||
|
||||
// Setup sets up a file system on disk and directory that is cleaned after
|
||||
// test completion.
|
||||
func Setup(t *testing.T) (filesys.FileSystem, filesys.ConfirmedDir) {
|
||||
t.Helper()
|
||||
|
||||
fSys := filesys.MakeFsOnDisk()
|
||||
dir, err := filesys.NewTmpConfirmedDir()
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
_ = fSys.RemoveAll(dir.String())
|
||||
})
|
||||
return fSys, dir
|
||||
}
|
||||
|
||||
// CreateKustDir creates a file system on disk and a new directory
|
||||
// that holds a kustomization file with content. The directory is removed on
|
||||
// test completion.
|
||||
func CreateKustDir(t *testing.T, content string) (filesys.FileSystem, filesys.ConfirmedDir) {
|
||||
t.Helper()
|
||||
|
||||
fSys := filesys.MakeFsOnDisk()
|
||||
tmpDir, err := filesys.NewTmpConfirmedDir()
|
||||
require.NoError(t, err)
|
||||
fSys, tmpDir := Setup(t)
|
||||
require.NoError(t, fSys.WriteFile(filepath.Join(tmpDir.String(), "kustomization.yaml"), []byte(content)))
|
||||
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, fSys.RemoveAll(tmpDir.String()))
|
||||
})
|
||||
return fSys, tmpDir
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user