Every struct in a NodeConf with `lopt:"foo" set is now added as a command-line flag with the RecursiveCreateFlags call. For maps a struct with the key UNDEF is added so that it can be parsed out. As the flags for the command-line need variables which hold the values, for every map an element map[UNDEF] is added. When now calling the internal add, these map element can be filtered out and replace by the given name. (e.g., --netname) * rewrote node/profile add for recursive functions * rewrote node/profile set for recursive functions * rewrote node/profile list for recursive functions Signed-off-by: Christian Goll <cgoll@suse.com>
33 lines
727 B
Go
33 lines
727 B
Go
package node
|
|
|
|
import "testing"
|
|
|
|
func Test_Empty(t *testing.T) {
|
|
var netdev NetDevs
|
|
var netdevPtr *NetDevs
|
|
|
|
t.Run("test for empty", func(t *testing.T) {
|
|
if ObjectIsEmpty(netdev) != true {
|
|
t.Errorf("netdev must be empty")
|
|
}
|
|
})
|
|
t.Run("test for non empty", func(t *testing.T) {
|
|
netdev.Device = "foo"
|
|
if ObjectIsEmpty(netdev) == true {
|
|
t.Errorf("netdev must be non empty")
|
|
}
|
|
})
|
|
t.Run("test for nil pointer", func(t *testing.T) {
|
|
if ObjectIsEmpty(netdevPtr) != true {
|
|
t.Errorf("netdev must be empty")
|
|
}
|
|
})
|
|
t.Run("test for pointer assigned", func(t *testing.T) {
|
|
netdev.Ipaddr = "10.10.10.1"
|
|
netdevPtr = &netdev
|
|
if ObjectIsEmpty(netdevPtr) == true {
|
|
t.Errorf("netdev must be empty")
|
|
}
|
|
})
|
|
}
|