func (e *engine) renderTemplate(tpl tpl.Templater, outWriter io.Writer) error { var buffer bytes.Buffer err := tpl.Content(&buffer) if err != nil { return err } tmpl, err := template.New("tpl").Funcs(templateFuncs).Parse(buffer.String()) if err != nil { return err } return tmpl.Execute(outWriter, e.renderOptions) }
Expect(rootTemplate.FindTemplate(path)).ToNot(BeNil()) }) It("should include Autounattend.xml.disks.partial", func() { path := filepath.Join(tmpDir, "Autounattend.xml.disks.partial") Expect(rootTemplate.FindTemplate(path)).ToNot(BeNil()) }) It("should have template content", func() { expected := `Autounattend.xml.template {{define "disks"}} Autounattend.xml.disks.partial {{end}} {{define "oobe"}} Autounattend.xml.oobe.partial {{end}}` var buffer bytes.Buffer Expect(rootTemplate.Content(&buffer)).NotTo(HaveOccurred()) Expect(buffer.String()).To(Equal(expected)) }) }) }) Context("Nano", func() { BeforeEach(func() { osName = "nano" }) Describe("Autounattend.xml.template root template", func() { var rootTemplate tpl.Templater JustBeforeEach(func() { rootTemplate = templates.FindTemplate(filepath.Join(tmpDir, "Autounattend.xml.template")) }) It("should be found", func() {