mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-18 18:41:33 +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:
+4
-3
@@ -7,6 +7,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/environment"
|
||||
"github.com/helmfile/helmfile/pkg/filesystem"
|
||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||
"github.com/helmfile/helmfile/pkg/tmpl"
|
||||
)
|
||||
@@ -35,9 +36,9 @@ type Bus struct {
|
||||
Chart string
|
||||
|
||||
Env environment.Environment
|
||||
Fs *filesystem.FileSystem
|
||||
|
||||
ReadFile func(string) ([]byte, error)
|
||||
Logger *zap.SugaredLogger
|
||||
Logger *zap.SugaredLogger
|
||||
}
|
||||
|
||||
func (bus *Bus) Trigger(evt string, evtErr error, context map[string]interface{}) (bool, error) {
|
||||
@@ -100,7 +101,7 @@ func (bus *Bus) Trigger(evt string, evtErr error, context map[string]interface{}
|
||||
for k, v := range context {
|
||||
data[k] = v
|
||||
}
|
||||
render := tmpl.NewTextRenderer(bus.ReadFile, bus.BasePath, data)
|
||||
render := tmpl.NewTextRenderer(bus.Fs, bus.BasePath, data)
|
||||
|
||||
bus.Logger.Debugf("hook[%s]: triggered by event \"%s\"\n", name, evt)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"go.uber.org/zap/zaptest/observer"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/environment"
|
||||
ffs "github.com/helmfile/helmfile/pkg/filesystem"
|
||||
)
|
||||
|
||||
type runner struct {
|
||||
@@ -154,7 +155,7 @@ func TestTrigger(t *testing.T) {
|
||||
Namespace: "myns",
|
||||
Env: environment.Environment{Name: "prod"},
|
||||
Logger: zeLogger,
|
||||
ReadFile: readFile,
|
||||
Fs: &ffs.FileSystem{ReadFile: readFile},
|
||||
}
|
||||
|
||||
bus.Runner = &runner{}
|
||||
|
||||
Reference in New Issue
Block a user