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
+4 -4
View File
@@ -220,11 +220,11 @@ func (c *Context) ReadFile(filename string) (string, error) {
path = filepath.Join(c.basePath, filename)
}
if c.readFile == nil {
if c.fs.ReadFile == nil {
return "", fmt.Errorf("readFile is not implemented")
}
bytes, err := c.readFile(path)
bytes, err := c.fs.ReadFile(path)
if err != nil {
return "", err
}
@@ -239,7 +239,7 @@ func (c *Context) ReadDir(path string) ([]string, error) {
contextPath = filepath.Join(c.basePath, path)
}
entries, err := c.readDir(contextPath)
entries, err := c.fs.ReadDir(contextPath)
if err != nil {
return nil, fmt.Errorf("ReadDir %q: %w", contextPath, err)
}
@@ -262,7 +262,7 @@ func (c *Context) ReadDirEntries(path string) ([]fs.DirEntry, error) {
} else {
contextPath = filepath.Join(c.basePath, path)
}
entries, err := c.readDir(contextPath)
entries, err := c.fs.ReadDir(contextPath)
if err != nil {
return nil, fmt.Errorf("ReadDirEntries %q: %w", contextPath, err)
}