summaryrefslogtreecommitdiff
path: root/render_test.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2024-01-22 09:06:33 -0500
committerGitHub <noreply@github.com>2024-01-22 09:06:33 -0500
commit0ac3aa24bf2e4ada9c26fd9ef5b7f0ae8c6b6cfb (patch)
tree9a95f27eec1e77ef8bfefcb2810f7e41681627a5 /render_test.go
parentf837061f953bda1e8b42095c6dba0496de11d993 (diff)
Use go-fsimpl to read from datasources (#1336)
* Use go-fsimpl to read from datasources Signed-off-by: Dave Henderson <dhenderson@gmail.com> * trying to fix windows bug Signed-off-by: Dave Henderson <dhenderson@gmail.com> * attempts to fix some of the path madness Signed-off-by: Dave Henderson <dhenderson@gmail.com> * remove 'HOME' from expected env vars Signed-off-by: Dave Henderson <dhenderson@gmail.com> * more tweaks Signed-off-by: Dave Henderson <dhenderson@gmail.com> * lint fix Signed-off-by: Dave Henderson <dhenderson@gmail.com> --------- Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'render_test.go')
-rw-r--r--render_test.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/render_test.go b/render_test.go
index 45b22067..ab6f58f2 100644
--- a/render_test.go
+++ b/render_test.go
@@ -10,7 +10,7 @@ import (
"testing"
"testing/fstest"
- "github.com/hairyhenderson/gomplate/v4/data"
+ "github.com/hairyhenderson/go-fsimpl"
"github.com/hairyhenderson/gomplate/v4/internal/datafs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -24,7 +24,11 @@ func TestRenderTemplate(t *testing.T) {
_ = os.Chdir("/")
fsys := fstest.MapFS{}
- ctx := datafs.ContextWithFSProvider(context.Background(), datafs.WrappedFSProvider(fsys, "mem"))
+ fsp := fsimpl.NewMux()
+ fsp.Add(datafs.EnvFS)
+ fsp.Add(datafs.StdinFS)
+ fsp.Add(datafs.WrappedFSProvider(fsys, "mem", ""))
+ ctx := datafs.ContextWithFSProvider(context.Background(), fsp)
// no options - built-in function
tr := NewRenderer(Options{})
@@ -47,7 +51,7 @@ func TestRenderTemplate(t *testing.T) {
"world": {URL: wu},
},
})
- ctx = data.ContextWithStdin(ctx, strings.NewReader("hello"))
+ ctx = datafs.ContextWithStdin(ctx, strings.NewReader("hello"))
out = &bytes.Buffer{}
err = tr.Render(ctx, "test", `{{ .hi | toUpper }} {{ (ds "world") | toUpper }}`, out)
require.NoError(t, err)