unit test + nil check pointers

This commit is contained in:
MatthewHink
2022-04-09 08:56:43 -04:00
parent 86624a6980
commit 086401a07c
3 changed files with 46 additions and 3 deletions

View File

@@ -0,0 +1,40 @@
package node
import (
"testing"
"gopkg.in/yaml.v2"
"github.com/stretchr/testify/assert"
)
func TestNodeUpdate(t *testing.T) {
var nodeConfig = `
WW_INTERNAL: 43
nodeprofiles:
default:
comment: This profile is automatically included for each node
nodes:
n0000:
discoverable: true
profiles:
- default
network devices:
default:
onboot: true
device: eth0
hwaddr: 08:00:27:39:46:70
ipaddr: 10.0.8.150
`
var nodeYaml nodeYaml
err := yaml.Unmarshal([]byte(nodeConfig), &nodeYaml)
assert.NoError(t, err)
err = nodeYaml.NodeUpdate(
NodeInfo{
Id: Entry {
value: []string{"n0000"},
},
},
)
assert.NoError(t, err)
}