added unknown type test

This commit is contained in:
Shreyas Goenka 2023-05-17 14:05:06 +02:00
parent 05b3b6ca2e
commit 742edb5215
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 23 additions and 0 deletions

View File

@ -66,3 +66,26 @@ func TestTemplateSchemaCastFloatToInt(t *testing.T) {
assert.IsType(t, true, config["bool_val"])
assert.IsType(t, "abc", config["string_val"])
}
func TestTemplateSchemaCastFloatToIntFailsForUnknownTypes(t *testing.T) {
// define schema for config
schemaJson := `{
"foo": {
"type": "integer"
}
}`
var schema Schema
err := json.Unmarshal([]byte(schemaJson), &schema)
require.NoError(t, err)
// define the config
configJson := `{
"bar": true
}`
var config map[string]any
err = json.Unmarshal([]byte(configJson), &config)
require.NoError(t, err)
err = schema.CastFloatToInt(config)
assert.ErrorContains(t, err, "bar is not defined as an input parameter for the template")
}