Skip to content

Commit

Permalink
add test for wrong collection type
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed Jan 31, 2025
1 parent 0b42dc3 commit 8611fa3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/runtime/internal/controller/node_config_foreach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ func TestNonAlphaNumericString(t *testing.T) {
require.ElementsMatch(t, customComponentIds, []string{"foreach_123__st_4__1"})
}

func TestCollectionNonArrayValue(t *testing.T) {
config := `foreach "default" {
collection = "aaa"
var = "num"
template {
}
}`
foreachConfigNode := NewForeachConfigNode(getBlockFromConfig(t, config), getComponentGlobals(t), nil)
require.ErrorContains(t, foreachConfigNode.Evaluate(vm.NewScope(make(map[string]interface{}))), `"aaa" should be array, got string`)
}

func getBlockFromConfig(t *testing.T, config string) *ast.BlockStmt {
file, err := parser.ParseFile("", []byte(config))
require.NoError(t, err)
Expand Down

0 comments on commit 8611fa3

Please sign in to comment.