mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-08 06:02:35 +02:00
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:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/filesystem"
|
||||
"github.com/helmfile/helmfile/pkg/tmpl"
|
||||
)
|
||||
|
||||
@@ -276,7 +277,7 @@ func TestFileRendering(t *testing.T) {
|
||||
|
||||
filename := fmt.Sprintf("%s/%s.gotmpl", tempDir, tc.name)
|
||||
os.WriteFile(filename, []byte(tc.tmplString), 0644)
|
||||
fileRenderer := tmpl.NewFileRenderer(os.ReadFile, ".", tc.data)
|
||||
fileRenderer := tmpl.NewFileRenderer(filesystem.DefaultFileSystem(), ".", tc.data)
|
||||
tmpl_bytes, err := fileRenderer.RenderToBytes(filename)
|
||||
|
||||
if tc.wantErr {
|
||||
@@ -294,8 +295,7 @@ func TestFileRendering(t *testing.T) {
|
||||
func TestTmplStrings(t *testing.T) {
|
||||
c := &tmpl.Context{}
|
||||
c.SetBasePath(".")
|
||||
c.SetReadFile(os.ReadFile)
|
||||
c.SetReadDir(os.ReadDir)
|
||||
c.SetFileSystem(filesystem.DefaultFileSystem())
|
||||
tmpl := template.New("stringTemplateTest").Funcs(c.CreateFuncMap())
|
||||
|
||||
tmplE2eTest.load()
|
||||
|
||||
Reference in New Issue
Block a user