summaryrefslogtreecommitdiff
path: root/template_windows_test.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2022-05-29 10:58:39 -0400
committerDave Henderson <dhenderson@gmail.com>2022-05-29 11:12:11 -0400
commitb2df8f62bc47adb58889b273434c9f16c03301d6 (patch)
tree40aada3f3fb0c90124a11c8ee71a25f04f369ef1 /template_windows_test.go
parentd9b8de8065d05ccd46e5a323f5675a46acfa183c (diff)
Simplify template processing
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'template_windows_test.go')
-rw-r--r--template_windows_test.go29
1 files changed, 19 insertions, 10 deletions
diff --git a/template_windows_test.go b/template_windows_test.go
index 4e678670..3990aa9f 100644
--- a/template_windows_test.go
+++ b/template_windows_test.go
@@ -1,22 +1,26 @@
//go:build windows
-// +build windows
package gomplate
import (
+ "context"
"testing"
+ "github.com/hairyhenderson/gomplate/v3/internal/config"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
)
func TestWalkDir(t *testing.T) {
+ ctx := context.Background()
origfs := fs
defer func() { fs = origfs }()
fs = afero.NewMemMapFs()
- _, err := walkDir(`C:\indir`, simpleNamer(`C:\outdir`), nil, 0, false)
+ cfg := &config.Config{}
+
+ _, err := walkDir(ctx, cfg, `C:\indir`, simpleNamer(`C:\outdir`), nil, 0, false)
assert.Error(t, err)
_ = fs.MkdirAll(`C:\indir\one`, 0777)
@@ -25,20 +29,25 @@ func TestWalkDir(t *testing.T) {
afero.WriteFile(fs, `C:\indir\one\bar`, []byte("bar"), 0644)
afero.WriteFile(fs, `C:\indir\two\baz`, []byte("baz"), 0644)
- templates, err := walkDir(`C:\indir`, simpleNamer(`C:\outdir`), []string{`*\two`}, 0, false)
+ templates, err := walkDir(ctx, cfg, `C:\indir`, simpleNamer(`C:\outdir`), []string{`*\two`}, 0, false)
assert.NoError(t, err)
expected := []*tplate{
{
- name: `C:\indir\one\bar`,
- targetPath: `C:\outdir\one\bar`,
- mode: 0644,
+ name: `C:\indir\one\bar`,
+ contents: "bar",
+ mode: 0644,
},
{
- name: `C:\indir\one\foo`,
- targetPath: `C:\outdir\one\foo`,
- mode: 0644,
+ name: `C:\indir\one\foo`,
+ contents: "foo",
+ mode: 0644,
},
}
- assert.EqualValues(t, expected, templates)
+ assert.Len(t, templates, 2)
+ for i, tmpl := range templates {
+ assert.Equal(t, expected[i].name, tmpl.name)
+ assert.Equal(t, expected[i].contents, tmpl.contents)
+ assert.Equal(t, expected[i].mode, tmpl.mode)
+ }
}