Skip to content

Commit

Permalink
assertions repeat endpoint code.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Mar 19, 2024
1 parent 09579a4 commit f4d4343
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ gem "minitest", "~> 5.0"
# gem "trailblazer-test", path: "../trailblazer-test"
gem "trailblazer-test", github: "trailblazer/trailblazer-test"

gem "trailblazer-endpoint", path: "../trailblazer-endpoint"
gem "trailblazer-macro", path: "../trailblazer-macro"
24 changes: 14 additions & 10 deletions lib/trailblazer/workflow/test/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,25 @@ def self.error_message_for(position, expected_position, **options) # TODO: test
# Grab the start_position and expected_lane_positions from the discovered plan, run
# the collaboration from there and check if it actually reached the expected configuration.
def assert_advance(event_label, test_plan:, schema:, ctx: {seq: []}, flow_options: {}, invalid: false, **) # TODO: allow {ctx}
# TODO: this is endpoint code!
# TODO: this is endpoint code! should we use endpoint here?
ctx_for_advance = Trailblazer::Context(ctx, {}, flow_options[:context_options])
flow_options = {throw: []}.merge(flow_options)
flow_options = {throw: []}.
merge(flow_options).
merge(
event_label: event_label,
iteration_set: test_plan,
**schema.to_h
)

# configuration, (ctx, flow) = Collaboration::Advance.(
signal, (ctx, flow), configuration = Workflow::Advance.(
ctx_for_advance, #flow_options, # DISCUSS: add circuit_options? #FIXME: this sucks
event_label: event_label,
iteration_set: test_plan,
**schema.to_h
)
signal, (ctx, flow_options) = Workflow::Advance.([ctx_for_advance, flow_options], # TODO: use (#invoke)
)# DISCUSS: add circuit_options? #FIXME: this sucks

configuration = flow_options[:configuration]

# we're expecting an invalid transition.
if invalid
assert_equal signal, Trailblazer::Workflow::Advance::UNAUTHORIZED_SIGNAL
# assert_equal signal.to_h[:semantic], :failure # TODO: reuse endpoint/matcher
assert [:failure, :not_authorized].include?(signal.to_h[:semantic]) # TODO: reuse endpoint/matcher
return ctx # FIXME: test this!
end

Expand Down

0 comments on commit f4d4343

Please sign in to comment.