Skip to content

Commit

Permalink
add test to discuss #65.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Dec 7, 2023
1 parent 039bd9a commit 67573d4
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions test/call_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ class Update < Trailblazer::Operation
result.event.must_equal Update.to_h[:outputs].find { |output| output.semantic == :failure }.signal
end

def self.add_1(wrap_ctx, original_args)
ctx, = original_args[0]
ctx[:seq] << 1
return wrap_ctx, original_args # yay to mutable state. not.
end

it "invokes with the taskWrap" do
operation = Class.new(Trailblazer::Operation) do
include Trailblazer::Activity::Testing.def_steps(:a)

def self.add_1(wrap_ctx, original_args)
ctx, = original_args[0]
ctx[:seq] << 1
return wrap_ctx, original_args # yay to mutable state. not.
end

merge = [
[Trailblazer::Activity::TaskWrap::Pipeline.method(:insert_before), "task_wrap.call_task", ["user.add_1", method(:add_1)]]
[Trailblazer::Activity::TaskWrap::Pipeline.method(:insert_before), "task_wrap.call_task", ["user.add_1", CallTest.method(:add_1)]]
]

step :a, extensions: [Trailblazer::Activity::TaskWrap::Extension(merge: merge)]
Expand All @@ -70,4 +70,27 @@ def self.add_1(wrap_ctx, original_args)

result.wtf?
end


it "calls with the taskWrap defined for operation using circuit interface" do
operation = Class.new(Trailblazer::Operation) do
include Trailblazer::Activity::Testing.def_steps(:a)

step :a
end

my_extension = Trailblazer::Activity::TaskWrap::Extension(
[CallTest.method(:add_1), id: "my.add_1", append: "task_wrap.call_task"]
)

# circuit interface invocation using call
signal, (ctx, _) = operation.call(
[{seq: []}, {}],
wrap_runtime: Hash.new(my_extension),
runner: Trailblazer::Activity::TaskWrap::Runner
)

assert_equal signal.to_h[:semantic], :success
assert_equal ctx[:seq], [1, :a, 1, 1]
end
end

0 comments on commit 67573d4

Please sign in to comment.