added check if commas can be set

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2023-09-29 11:42:00 +02:00
committed by Jonathon Anderson
parent 57a5e7d5ba
commit dcb21af5ba
3 changed files with 36 additions and 4 deletions

View File

@@ -2,9 +2,12 @@ package set
import (
"bytes"
"os"
"testing"
"github.com/stretchr/testify/assert"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/testenv"
"github.com/warewulf/warewulf/internal/pkg/warewulfd"
)
@@ -408,8 +411,40 @@ nodes:
- p2
tags:
nodetag1: nodevalue1
`},
{name: "single node set comma in comment",
args: []string{"n01", "--comment", "This is a , comment"},
wantErr: false,
stdout: "",
inDB: `WW_INTERNAL: 43
nodes:
n01:
comment: old comment
`,
outDb: `WW_INTERNAL: 43
nodeprofiles: {}
nodes:
n01:
comment: This is a , comment
profiles:
- default
`},
}
conf_yml := `WW_INTERNAL: 0`
tempWarewulfConf, warewulfConfErr := os.CreateTemp("", "warewulf.conf-")
assert.NoError(t, warewulfConfErr)
defer os.Remove(tempWarewulfConf.Name())
_, warewulfConfErr = tempWarewulfConf.Write([]byte(conf_yml))
assert.NoError(t, warewulfConfErr)
assert.NoError(t, tempWarewulfConf.Sync())
assert.NoError(t, warewulfconf.New().Read(tempWarewulfConf.Name()))
tempNodeConf, nodesConfErr := os.CreateTemp("", "nodes.conf-")
assert.NoError(t, nodesConfErr)
defer os.Remove(tempNodeConf.Name())
node.ConfigFile = tempNodeConf.Name()
warewulfd.SetNoDaemon()
for _, tt := range tests {
run_test(t, tt)
}