rendering complex additionalProperties in place.

slices of maps were not rendered properly. Now corrected, coverage continues to rise, refactoring node generation into utils package.
This commit is contained in:
Dave Shanley
2023-03-19 07:43:57 -04:00
parent 0b8fab869e
commit 0e8ae7c548
11 changed files with 176 additions and 112 deletions

View File

@@ -317,7 +317,7 @@ minProperties: 1`
// now render it out!
schemaBytes, _ := compiled.Render()
assert.Equal(t, testSpec, strings.TrimSpace(string(schemaBytes)))
assert.Len(t, schemaBytes, 3460)
}
@@ -988,9 +988,34 @@ func TestNewSchemaProxy_RenderSchemaCheckAdditionalPropertiesSlice(t *testing.T)
schemaProxy := NewSchemaProxy(&lowproxy)
compiled := schemaProxy.Schema()
compiled.low.Hash()
// now render it out, it should be identical.
schemaBytes, _ := compiled.Render()
assert.Len(t, schemaBytes, 91)
}
func TestNewSchemaProxy_RenderSchemaCheckAdditionalPropertiesSliceMap(t *testing.T) {
testSpec := `additionalProperties:
- nice: cake
- yummy: beer
- hot: coffee`
var compNode yaml.Node
_ = yaml.Unmarshal([]byte(testSpec), &compNode)
sp := new(lowbase.SchemaProxy)
err := sp.Build(compNode.Content[0], nil)
assert.NoError(t, err)
lowproxy := low.NodeReference[*lowbase.SchemaProxy]{
Value: sp,
ValueNode: compNode.Content[0],
}
schemaProxy := NewSchemaProxy(&lowproxy)
compiled := schemaProxy.Schema()
// now render it out, it should be identical.
schemaBytes, _ := compiled.Render()
assert.Equal(t, testSpec, strings.TrimSpace(string(schemaBytes)))
assert.Len(t, schemaBytes, 75)
}