-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add more unit tests for conditionals
- Loading branch information
1 parent
4cdeedf
commit 0a4df92
Showing
9 changed files
with
260 additions
and
9 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
tests/data/workflows/unit_conditional_adder_diamond_skip_with_join_strong_dep_fails.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
title: Adder diamond skip with join with strong depedency | ||
# A | ||
# /\ | ||
# B [C] <- C should not run | ||
# \ / | ||
# D <- D should fail, because it tries to access C's result | ||
description: | | ||
Initial conditions: | ||
- C fails | ||
- D has a strong dependency on C, meaning it's both structurally dependent and data dependent | ||
Expect: | ||
- Condition returns false | ||
- C does not run | ||
- D fails | ||
config: | ||
scheduler: dynamic | ||
entrypoint: a | ||
inputs: | ||
another_url: http://api:8000 | ||
value: 1 | ||
|
||
triggers: | ||
- type: webhook | ||
ref: my_webhook | ||
id: wh-XXXXXX | ||
entrypoint: a # This can be any | ||
args: | ||
url: http://api:8000/test/items/1 | ||
method: GET | ||
|
||
actions: | ||
- ref: a | ||
action: example.passthrough | ||
args: | ||
value: "1" | ||
|
||
- ref: b | ||
action: example.add | ||
args: | ||
lhs: ${{ ACTIONS.a.result -> int }} | ||
rhs: 1 | ||
depends_on: | ||
- a | ||
|
||
- ref: c | ||
action: example.add | ||
args: | ||
lhs: 3 | ||
rhs: ${{ ACTIONS.a.result -> int }} | ||
depends_on: | ||
- a | ||
# This expression returns false and the task should not run, as a.result is "1" | ||
run_if: ${{ FNS.is_equal(ACTIONS.a.result, str(2)) }} | ||
|
||
# This task should still run, as B runs | ||
- ref: d | ||
action: example.add | ||
args: | ||
lhs: ${{ ACTIONS.c.result -> int }} | ||
rhs: 4 | ||
depends_on: | ||
- b | ||
- c |
64 changes: 64 additions & 0 deletions
64
tests/data/workflows/unit_conditional_adder_diamond_skip_with_join_weak_dep.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
title: Adder diamond skip with join with weak depedency | ||
# A | ||
# /\ | ||
# B [C] <- C should not run | ||
# \ / | ||
# D <- D should still run, because it is not entirely dependent on C | ||
description: | | ||
Initial conditions: | ||
- C fails | ||
- D has a weak dependency on C, meaning it's only structurally dependent but not data dependent | ||
Expect: | ||
- Condition returns false | ||
- C does not run | ||
- D still runs | ||
config: | ||
scheduler: dynamic | ||
entrypoint: a | ||
inputs: | ||
another_url: http://api:8000 | ||
value: 1 | ||
|
||
triggers: | ||
- type: webhook | ||
ref: my_webhook | ||
id: wh-XXXXXX | ||
entrypoint: a # This can be any | ||
args: | ||
url: http://api:8000/test/items/1 | ||
method: GET | ||
|
||
actions: | ||
- ref: a | ||
action: example.passthrough | ||
args: | ||
value: "1" | ||
|
||
- ref: b | ||
action: example.add | ||
args: | ||
lhs: ${{ ACTIONS.a.result -> int }} | ||
rhs: 1 | ||
depends_on: | ||
- a | ||
|
||
- ref: c | ||
action: example.add | ||
args: | ||
lhs: 3 | ||
rhs: ${{ ACTIONS.a.result -> int }} | ||
depends_on: | ||
- a | ||
# This expression returns false and the task should not run, as a.result is "1" | ||
run_if: ${{ FNS.is_equal(ACTIONS.a.result, str(2)) }} | ||
|
||
# This task should still run, as B runs | ||
- ref: d | ||
action: example.add | ||
args: | ||
lhs: ${{ ACTIONS.b.result -> int }} | ||
rhs: 4 | ||
depends_on: | ||
- b | ||
- c |
13 changes: 13 additions & 0 deletions
13
tests/data/workflows/unit_conditional_adder_diamond_skip_with_join_weak_dep_expected.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ACTIONS: | ||
a: | ||
result: "1" | ||
result_typename: "str" | ||
b: | ||
result: 2 | ||
result_typename: "int" | ||
d: | ||
result: 6 | ||
result_typename: "int" | ||
INPUTS: | ||
another_url: "http://api:8000" | ||
value: 1 |
File renamed without changes.
56 changes: 56 additions & 0 deletions
56
tests/data/workflows/unit_conditional_adder_tree_skip_propagates.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
title: Adder tree skips with propagation | ||
# A | ||
# /\ | ||
# B [C] <- C should not run | ||
# | | ||
# [D] <- D should not run as its entirely dependent on C | ||
description: Test that the condition returns false and C, D does not run | ||
config: | ||
scheduler: dynamic | ||
entrypoint: a | ||
inputs: | ||
another_url: http://api:8000 | ||
value: 1 | ||
|
||
triggers: | ||
- type: webhook | ||
ref: my_webhook | ||
id: wh-XXXXXX | ||
entrypoint: a # This can be any | ||
args: | ||
url: http://api:8000/test/items/1 | ||
method: GET | ||
|
||
actions: | ||
- ref: a | ||
action: example.passthrough | ||
args: | ||
value: "1" | ||
|
||
- ref: b | ||
action: example.add | ||
args: | ||
# Demonstrate casting | ||
lhs: ${{ ACTIONS.a.result -> int }} | ||
rhs: 1 | ||
depends_on: | ||
- a | ||
|
||
- ref: c | ||
action: example.add | ||
args: | ||
lhs: 3 | ||
rhs: ${{ ACTIONS.a.result -> int }} | ||
depends_on: | ||
- a | ||
# This expression returns false and the task should not run, as a.result is "1" | ||
run_if: ${{ FNS.is_equal(ACTIONS.a.result, str(2)) }} | ||
|
||
# This task should not run, as C does not run | ||
- ref: d | ||
action: example.add | ||
args: | ||
lhs: 4 | ||
rhs: ${{ ACTIONS.c.result -> int }} | ||
depends_on: | ||
- c |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...lows/unit_conditional_adder_tree_halt.yml → ...ows/unit_conditional_adder_tree_skips.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
title: Adder tree 1 Workflow | ||
title: Adder tree skips | ||
# A | ||
# /\ | ||
# B [C] <- C should not run | ||
|
10 changes: 10 additions & 0 deletions
10
tests/data/workflows/unit_conditional_adder_tree_skips_expected.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ACTIONS: | ||
a: | ||
result: "1" | ||
result_typename: "str" | ||
b: | ||
result: 2 | ||
result_typename: "int" | ||
INPUTS: | ||
another_url: "http://api:8000" | ||
value: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters