Added another test to check slices of bools in model_builder

Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
Dave Shanley
2023-04-30 08:56:38 -04:00
parent f339dc0125
commit 08c9ca8c26

View File

@@ -337,11 +337,6 @@ func TestSetField_Default_Helper(t *testing.T) {
func TestHandleSlicesOfInts(t *testing.T) { func TestHandleSlicesOfInts(t *testing.T) {
type cake struct {
thing int
}
// this should be ignored, no custom objects in here my friend.
type internal struct { type internal struct {
Thing NodeReference[[]ValueReference[any]] Thing NodeReference[[]ValueReference[any]]
} }
@@ -361,6 +356,26 @@ func TestHandleSlicesOfInts(t *testing.T) {
assert.Equal(t, 1.234, ins.Thing.Value[1].Value) assert.Equal(t, 1.234, ins.Thing.Value[1].Value)
} }
func TestHandleSlicesOfBools(t *testing.T) {
type internal struct {
Thing NodeReference[[]ValueReference[any]]
}
yml := `thing:
- true
- false`
ins := new(internal)
var rootNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &rootNode)
assert.NoError(t, mErr)
try := BuildModel(rootNode.Content[0], ins)
assert.NoError(t, try)
assert.Equal(t, true, ins.Thing.Value[0].Value)
assert.Equal(t, false, ins.Thing.Value[1].Value)
}
func TestSetField_Ignore(t *testing.T) { func TestSetField_Ignore(t *testing.T) {
type Complex struct { type Complex struct {