From 08c9ca8c2609052ef297dcfdf07ebbf57d90bf68 Mon Sep 17 00:00:00 2001 From: Dave Shanley Date: Sun, 30 Apr 2023 08:56:38 -0400 Subject: [PATCH] Added another test to check slices of bools in `model_builder` Signed-off-by: Dave Shanley --- datamodel/low/model_builder_test.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/datamodel/low/model_builder_test.go b/datamodel/low/model_builder_test.go index b33d0cc..5a8eb77 100644 --- a/datamodel/low/model_builder_test.go +++ b/datamodel/low/model_builder_test.go @@ -337,11 +337,6 @@ func TestSetField_Default_Helper(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 { Thing NodeReference[[]ValueReference[any]] } @@ -361,6 +356,26 @@ func TestHandleSlicesOfInts(t *testing.T) { 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) { type Complex struct {