From 82ded80fcef1965ab5357a89d201811436b5d8d7 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 29 May 2022 11:49:57 -0400 Subject: Stop passing the config in the context Signed-off-by: Dave Henderson --- template_test.go | 98 -------------------------------------------------------- 1 file changed, 98 deletions(-) (limited to 'template_test.go') diff --git a/template_test.go b/template_test.go index d28ecacd..fc730693 100644 --- a/template_test.go +++ b/template_test.go @@ -158,104 +158,6 @@ func TestGatherTemplates(t *testing.T) { fs.Remove("out") } -// func TestProcessTemplates(t *testing.T) { -// origfs := fs -// defer func() { fs = origfs }() -// fs = afero.NewMemMapFs() -// afero.WriteFile(fs, "foo", []byte("bar"), iohelpers.NormalizeFileMode(0600)) - -// afero.WriteFile(fs, "in/1", []byte("foo"), iohelpers.NormalizeFileMode(0644)) -// afero.WriteFile(fs, "in/2", []byte("bar"), iohelpers.NormalizeFileMode(0640)) -// afero.WriteFile(fs, "in/3", []byte("baz"), iohelpers.NormalizeFileMode(0644)) - -// afero.WriteFile(fs, "existing", []byte(""), iohelpers.NormalizeFileMode(0644)) - -// cfg := &config.Config{ -// Stdout: &bytes.Buffer{}, -// } -// testdata := []struct { -// templates []*tplate -// contents []string -// modes []os.FileMode -// targets []io.Writer -// }{ -// {}, -// { -// templates: []*tplate{{name: "", contents: "foo", targetPath: "-", mode: 0644}}, -// contents: []string{"foo"}, -// modes: []os.FileMode{0644}, -// targets: []io.Writer{cfg.Stdout}, -// }, -// { -// templates: []*tplate{{name: "", contents: "foo", targetPath: "out", mode: 0644}}, -// contents: []string{"foo"}, -// modes: []os.FileMode{0644}, -// }, -// { -// templates: []*tplate{{name: "foo", targetPath: "out", mode: 0600}}, -// contents: []string{"bar"}, -// modes: []os.FileMode{0600}, -// }, -// { -// templates: []*tplate{{name: "foo", targetPath: "out", mode: 0755}}, -// contents: []string{"bar"}, -// modes: []os.FileMode{0755}, -// }, -// { -// templates: []*tplate{ -// {name: "in/1", targetPath: "out/1", mode: 0644}, -// {name: "in/2", targetPath: "out/2", mode: 0640}, -// {name: "in/3", targetPath: "out/3", mode: 0644}, -// }, -// contents: []string{"foo", "bar", "baz"}, -// modes: []os.FileMode{0644, 0640, 0644}, -// }, -// { -// templates: []*tplate{ -// {name: "foo", targetPath: "existing", mode: 0755}, -// }, -// contents: []string{"bar"}, -// modes: []os.FileMode{0644}, -// }, -// { -// templates: []*tplate{ -// {name: "foo", targetPath: "existing", mode: 0755, modeOverride: true}, -// }, -// contents: []string{"bar"}, -// modes: []os.FileMode{0755}, -// }, -// } -// for i, in := range testdata { -// in := in -// t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { -// actual, err := processTemplates(cfg, in.templates) -// assert.NoError(t, err) -// assert.Len(t, actual, len(in.templates)) -// for i, a := range actual { -// current := in.templates[i] -// assert.Equal(t, in.contents[i], a.contents) -// assert.Equal(t, current.mode, a.mode) -// if len(in.targets) > 0 { -// assert.Equal(t, in.targets[i], a.target) -// } -// if current.targetPath != "-" && current.name != "" { -// _, err = current.loadContents(nil) -// assert.NoError(t, err) - -// n, err := current.target.Write([]byte("hello world")) -// assert.NoError(t, err) -// assert.Equal(t, 11, n) - -// info, err := fs.Stat(current.targetPath) -// assert.NoError(t, err) -// assert.Equal(t, iohelpers.NormalizeFileMode(in.modes[i]), info.Mode()) -// } -// } -// fs.Remove("out") -// }) -// } -// } - func TestCreateOutFile(t *testing.T) { origfs := fs defer func() { fs = origfs }() -- cgit v1.2.3