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 Executor Tests #131

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions workflow/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (e *executor) verifyStageInputs(
if providedInputForField == nil {
// not present
if stageInputSchema.RequiredValue {
return fmt.Errorf("required input %s of type %s not found for step %s",
return fmt.Errorf("required input '%s' of type '%s' not found for step '%s'",
name, stageInputSchema.TypeID(), stepID)
}
} else {
Expand Down Expand Up @@ -773,8 +773,8 @@ func (e *executor) prepareDependencies( //nolint:gocognit,gocyclo
for _, dependency := range dependencies {
dependencyKind := dependency[1]
switch dependencyKind {
case "input":
inputNode, err := dag.GetNodeByID("input")
case WorkflowInputKey:
inputNode, err := dag.GetNodeByID(WorkflowInputKey)
if err != nil {
return fmt.Errorf("failed to find input node (%w)", err)
}
Expand All @@ -784,7 +784,7 @@ func (e *executor) prepareDependencies( //nolint:gocognit,gocyclo
return fmt.Errorf("failed to connect input to %s (%w)", currentNode.ID(), err)
}
}
case "steps":
case WorkflowStepsKey:
var prevNodeID string
switch dependencyNodes := len(dependency); {
case dependencyNodes == 4: // Example: $.steps.example.outputs
Expand Down
21 changes: 17 additions & 4 deletions workflow/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ input:
properties: {}
steps:
incomplete_wait:
plugin: "n/a"
plugin:
src: "n/a"
deployment_type: builtin
step: wait
# Missing input
outputs:
Expand Down Expand Up @@ -155,9 +157,12 @@ func TestMissingInput(t *testing.T) {
// For this test, a workflow's step will be missing its inputs.
_, err := getTestImplPreparedWorkflow(t, missingInputWorkflowDefinition1)
assert.Error(t, err)
assert.Contains(t, err.Error(), "required input 'input' of type 'scope' not found for step 'incomplete_wait'")

_, err = getDummyDeployerPreparedWorkflow(t, missingInputWorkflowDefinition2)
assert.Error(t, err)
assert.Contains(t, err.Error(), "required input 'name' of type 'string' not found for step 'say_hi'")

}

var mismatchedStepInputTypesWorkflowDefinition = `
Expand All @@ -170,12 +175,16 @@ input:
properties: {}
steps:
wait_1:
plugin: "n/a"
plugin:
src: "n/a"
deployment_type: builtin
step: wait
input:
wait_time_ms: 0
wait_2:
plugin: "n/a"
plugin:
src: "n/a"
deployment_type: builtin
step: wait
input:
# Should fail during preparation, due to message being a string, and wait_time_ms expecting an int
Expand All @@ -188,6 +197,7 @@ outputs:
func TestMismatchedStepInputTypes(t *testing.T) {
_, err := getTestImplPreparedWorkflow(t, mismatchedStepInputTypesWorkflowDefinition)
assert.Error(t, err)
assert.Contains(t, err.Error(), "unsupported data type for 'int' type: *schema.StringSchema")
}

var mismatchedInputTypesWorkflowDefinition = `
Expand All @@ -207,7 +217,9 @@ input:
type_id: string
steps:
wait_1:
plugin: "n/a"
plugin:
src: "n/a"
deployment_type: builtin
step: wait
input:
# This is trying to put a string into an int field
Expand All @@ -220,4 +232,5 @@ outputs:
func TestMismatchedInputTypes(t *testing.T) {
_, err := getTestImplPreparedWorkflow(t, mismatchedInputTypesWorkflowDefinition)
assert.Error(t, err)
assert.Contains(t, err.Error(), "unsupported data type for 'int' type: *schema.StringSchema")
}
Loading