diff --git a/go.mod b/go.mod index ad96ebb2..cc0bf937 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( go.arcalot.io/log/v2 v2.1.0 go.flow.arcalot.io/deployer v0.6.0-beta1 go.flow.arcalot.io/dockerdeployer v0.7.0 - go.flow.arcalot.io/expressions v0.4.1 + go.flow.arcalot.io/expressions v0.4.2 go.flow.arcalot.io/kubernetesdeployer v0.9.1 go.flow.arcalot.io/pluginsdk v0.12.0 go.flow.arcalot.io/podmandeployer v0.11.0 diff --git a/go.sum b/go.sum index 364015b5..fb88809f 100644 --- a/go.sum +++ b/go.sum @@ -139,8 +139,8 @@ go.flow.arcalot.io/deployer v0.6.0-beta1 h1:6wVGi/D5rHcT1pnQETg9ZAq5PCxArPwg0MNj go.flow.arcalot.io/deployer v0.6.0-beta1/go.mod h1:MDaDc9xDRjQN5TyTvvKMXipc5Khe8NLOnUjh31Nm0wU= go.flow.arcalot.io/dockerdeployer v0.7.0 h1:zQi/r5FVi1MBD4Z+I9l0i4nUQvjBSaZXdhtVKs3zPcM= go.flow.arcalot.io/dockerdeployer v0.7.0/go.mod h1:xIPCRSnyb/JEitUzsY2deWa7VwVZJd+opLNcFTcrN8U= -go.flow.arcalot.io/expressions v0.4.1 h1:WOl3DtDcWAmPKupwYxJV3bVYKPoMgAmQbECfiUgv/0s= -go.flow.arcalot.io/expressions v0.4.1/go.mod h1:FA/50wX1+0iTgW/dFeeE1yOslZSmfBaMNR4IiMYRwxc= +go.flow.arcalot.io/expressions v0.4.2 h1:nEfxpWGEG1+59CoiAnS3AUQ+j2RZcUSPhPGjwPd+wOA= +go.flow.arcalot.io/expressions v0.4.2/go.mod h1:FA/50wX1+0iTgW/dFeeE1yOslZSmfBaMNR4IiMYRwxc= go.flow.arcalot.io/kubernetesdeployer v0.9.1 h1:AGnJFazehAENXxGMCF0Uc7aG9F0LpvuhoyQFu8deJG0= go.flow.arcalot.io/kubernetesdeployer v0.9.1/go.mod h1:yvxT3VwmyrlIi4422pxl02z4QeU2Gvbjg5aQB17Ye4s= go.flow.arcalot.io/pluginsdk v0.12.0 h1:NJyPMluwtljsNjEEewCeuxE2dGuAJn89KvU52o9OAvU= diff --git a/workflow/workflow_test.go b/workflow/workflow_test.go index 657b91e2..dc8bb471 100644 --- a/workflow/workflow_test.go +++ b/workflow/workflow_test.go @@ -1328,6 +1328,45 @@ 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.success.message" + trailing-whitespace: !expr "$.steps.wait_1.outputs.success.message " + # Use | instead of |- to keep the newline at the end. + trailing-newline: !expr | + $.steps.wait_1.outputs.success.message +` + +func TestExpressionWithWhitespace(t *testing.T) { + preparedWorkflow := assert.NoErrorR[workflow.ExecutableWorkflow](t)( + getTestImplPreparedWorkflow(t, testExpressionWithExtraWhitespace), + ) + outputID, outputData, err := preparedWorkflow.Execute(context.Background(), map[string]any{}) + assert.NoError(t, err) + assert.Equals(t, outputID, "a") + assert.Equals(t, outputData.(map[any]any), map[any]any{ + "leading-whitespace": "Plugin slept for 0 ms.", + "trailing-whitespace": "Plugin slept for 0 ms.", + "trailing-newline": "Plugin slept for 0 ms.", + }) +} + func createTestExecutableWorkflow(t *testing.T, workflowStr string, workflowCtx map[string][]byte) (workflow.ExecutableWorkflow, error) { logConfig := log.Config{ Level: log.LevelDebug,