Introduce Helmfile's own filesystem abstraction to correctly unit test some components (#307)

Use abstracted FS

Signed-off-by: Arkaitz Jimenez <arkaitzj@gmail.com>

Signed-off-by: Arkaitz Jimenez <arkaitzj@gmail.com>
This commit is contained in:
Arkaitz Jimenez
2022-08-24 12:58:43 +09:00
committed by GitHub
parent a626664f46
commit cc33e7b7d8
44 changed files with 513 additions and 425 deletions
+3 -7
View File
@@ -1,13 +1,12 @@
package state
import (
"os"
"path/filepath"
"testing"
"github.com/google/go-cmp/cmp"
"go.uber.org/zap"
ffs "github.com/helmfile/helmfile/pkg/filesystem"
"github.com/helmfile/helmfile/pkg/remote"
)
@@ -22,14 +21,11 @@ func newLoader() *EnvironmentValuesLoader {
storage := &Storage{
FilePath: "./helmfile.yaml",
basePath: ".",
glob: filepath.Glob,
fs: ffs.DefaultFileSystem(),
logger: sugar,
}
readFile := func(s string) ([]byte, error) { return []byte{}, nil }
dirExists := func(d string) bool { return false }
fileExists := func(f string) bool { return false }
return NewEnvironmentValuesLoader(storage, os.ReadFile, sugar, remote.NewRemote(sugar, "/tmp", readFile, dirExists, fileExists))
return NewEnvironmentValuesLoader(storage, storage.fs, sugar, remote.NewRemote(sugar, "/tmp", storage.fs))
}
// See https://github.com/roboll/helmfile/pull/1169