Skip to content

Commit

Permalink
Allow passing custom :flow_options to Testing#assert_invoke.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Sep 14, 2023
1 parent ee84cf7 commit 73b4fb8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.16.2

* Allow passing custom `:flow_options` to `Testing#assert_invoke`.

# 0.16.1

* Allow overriding `Activity.call`.
Expand Down
4 changes: 2 additions & 2 deletions lib/trailblazer/activity/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def assert_call(activity, terminus: :success, seq: "[]", expected_ctx_variables:
end

# Use {TaskWrap.invoke} to call the activity.
def assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, expected_ctx_variables: {}, **ctx_variables)
def assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, flow_options: {}, expected_ctx_variables: {}, **ctx_variables)
signal, (ctx, _flow_options) = Activity::TaskWrap.invoke(
activity,
[
{seq: [], **ctx_variables},
{} # flow_options
flow_options,
],
**circuit_options
)
Expand Down
17 changes: 16 additions & 1 deletion test/testing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,24 @@ def invisible
let(:activity) { MyActivity }

#0001
#@ test that we can pass {:circuit_options}
it {
ctx = assert_invoke activity, seq: "[:call]", circuit_options: {start: "yes"}

assert_equal ctx.invisible[:circuit_options].keys.inspect, %([:start, :runner, :wrap_runtime, :activity])
assert_equal ctx.invisible[:circuit_options][:start], "yes"
}


#0002
#@ test that we can pass {:flow_options}
it {
ctx = assert_invoke activity, seq: "[:call]", flow_options: {start: "yes"}

assert_equal ctx.invisible[:flow_options].keys.inspect, %([:start])
assert_equal ctx.invisible[:flow_options][:start], "yes"
}

# #0002
# #@ allows {:terminus}
# it { assert_call activity, seq: "[:b]", terminus: :failure, b: Trailblazer::Activity::Left }
Expand Down Expand Up @@ -213,8 +224,12 @@ def invisible

test_case = test.new(:test_0001_anonymous)
failures = test_case.()
puts failures
assert_equal failures.size, 0

test_case = test.new(:test_0002_anonymous)
failures = test_case.()
puts failures
assert_equal failures.size, 0

end
end

0 comments on commit 73b4fb8

Please sign in to comment.