github.com/hairyhenderson/templater@v3.5.0+incompatible/template_windows_test.go (about) 1 // +build windows 2 3 package gomplate 4 5 import ( 6 "testing" 7 8 "github.com/spf13/afero" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestWalkDir(t *testing.T) { 14 origfs := fs 15 defer func() { fs = origfs }() 16 fs = afero.NewMemMapFs() 17 18 _, err := walkDir(`C:\indir`, simpleNamer(`C:\outdir`), nil, 0, false) 19 assert.Error(t, err) 20 21 _ = fs.MkdirAll(`C:\indir\one`, 0777) 22 _ = fs.MkdirAll(`C:\indir\two`, 0777) 23 afero.WriteFile(fs, `C:\indir\one\foo`, []byte("foo"), 0644) 24 afero.WriteFile(fs, `C:\indir\one\bar`, []byte("bar"), 0644) 25 afero.WriteFile(fs, `C:\indir\two\baz`, []byte("baz"), 0644) 26 27 templates, err := walkDir(`C:\indir`, simpleNamer(`C:\outdir`), []string{`*\two`}, 0, false) 28 29 assert.NoError(t, err) 30 expected := []*tplate{ 31 { 32 name: `C:\indir\one\bar`, 33 targetPath: `C:\outdir\one\bar`, 34 mode: 0644, 35 }, 36 { 37 name: `C:\indir\one\foo`, 38 targetPath: `C:\outdir\one\foo`, 39 mode: 0644, 40 }, 41 } 42 assert.EqualValues(t, expected, templates) 43 }