Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest expression dependency version #184

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions workflow/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,41 @@ func TestDelayedDisabledStepWorkflow(t *testing.T) {
assert.Equals(t, toggledOutputMap["message"], "Step toggled_wait/wait disabled")
}

var testExpressionWithExtraWhitespace = `
version: v0.2.0
input:
root: RootObject
objects:
RootObject:
id: RootObject
properties: {}
steps:
wait_1:
plugin:
src: "n/a"
deployment_type: "builtin"
step: wait
input:
wait_time_ms: 0
outputs:
a:
leading-whitespace: !expr " $.steps.wait_1.outputs"
trailing-whitespace: !expr "$.steps.wait_1.outputs "
# Use | instead of |- to keep the newline at the end.
trailing-newline: !expr |
$.steps.wait_1.outputs
`

func TestExpressionWithWhitespace(t *testing.T) {
// Just a single wait
preparedWorkflow := assert.NoErrorR[workflow.ExecutableWorkflow](t)(
getTestImplPreparedWorkflow(t, testExpressionWithExtraWhitespace),
)
outputID, _, err := preparedWorkflow.Execute(context.Background(), map[string]any{})
jaredoconnell marked this conversation as resolved.
Show resolved Hide resolved
assert.NoError(t, err)
assert.Equals(t, outputID, "a")
}

func createTestExecutableWorkflow(t *testing.T, workflowStr string, workflowCtx map[string][]byte) (workflow.ExecutableWorkflow, error) {
logConfig := log.Config{
Level: log.LevelDebug,
Expand Down
2 changes: 1 addition & 1 deletion workflow/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func yamlBuildExpressions(data yaml.Node, path []string) (any, error) {
if data.Type() != yaml.TypeIDString {
return nil, fmt.Errorf("!!expr found on non-string node at %s", strings.Join(path, " -> "))
}
expr, err := expressions.New(data.Value())
expr, err := expressions.New(strings.TrimSpace(data.Value()))
if err != nil {
return nil, fmt.Errorf("failed to compile expression at %s (%w)", strings.Join(path, " -> "), err)
}
Expand Down
Loading