Remove testenv.WriteFileAbs

Writing absolute file names in testenv breaks safety that files in the
test environment are written to the designated temporary path. Adjusted
the relevant tests to use testenv.WriteFile.

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2023-11-25 23:50:01 -07:00
parent f8805e87a4
commit c8604bc200
3 changed files with 32 additions and 35 deletions

View File

@@ -5,7 +5,6 @@ import (
"path"
"testing"
warewulfconf "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/stretchr/testify/assert"
@@ -15,8 +14,7 @@ import (
func Test_Overlay_List(t *testing.T) {
env := testenv.New(t)
wwconf := warewulfconf.Get()
env.WriteFileAbs(t, path.Join(wwconf.Paths.WWOverlaydir, "testoverlay/email.ww"), `
env.WriteFile(t, path.Join(testenv.WWOverlaydir, "testoverlay/email.ww"), `
{{ if .Tags.email }}eMail: {{ .Tags.email }}{{else}} noMail{{- end }}
`)
defer env.RemoveAll(t)

View File

@@ -5,7 +5,6 @@ import (
"path"
"testing"
warewulfconf "github.com/hpcng/warewulf/internal/pkg/config"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/stretchr/testify/assert"
@@ -21,7 +20,6 @@ var (
func Test_Overlay_List(t *testing.T) {
env := testenv.New(t)
wwconf := warewulfconf.Get()
env.WriteFile(t, "etc/warewulf/nodes.conf",
`WW_INTERNAL: 43
nodeprofiles:
@@ -39,7 +37,7 @@ nodes:
- empty
`)
env.WriteFileAbs(t, path.Join(wwconf.Paths.WWOverlaydir, "testoverlay/email.ww"), overlayCont)
env.WriteFile(t, path.Join(testenv.WWOverlaydir, "testoverlay/email.ww"), overlayCont)
defer env.RemoveAll(t)
warewulfd.SetNoDaemon()
t.Run("overlay show raw", func(t *testing.T) {