Skip to content

Commit

Permalink
start writing more :strict tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Nov 20, 2023
1 parent 0305bca commit 5886121
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions test/docs/subprocess_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,84 @@ class Create < Trailblazer::Activity::Railway
end
end

class Strict_Exception_SubprocessDocsTest < Minitest::Spec
Memo = Class.new

module Memo::Activity
class Validate < Trailblazer::Activity::Railway
step :check_params,
Output(:failure) => End(:invalid)
step :text_present?
#~meths
include T.def_steps(:check_params, :text_present?)
#~meths end
end
end

module Memo::Activity
class Create < Trailblazer::Activity::Railway
step Subprocess(Validate) # no wiring of {:invalid} terminus.
step :save
left :handle_errors
step :notify
#~meths
include T.def_steps(:validate, :save, :handle_errors, :notify)
#~meths end
end
end

it "raises {IllegalSignalError} at runtime when not connected" do
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :save, :notify]"
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :save, :handle_errors]", save: false, terminus: :failure
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :handle_errors]", text_present?: false, terminus: :failure
exception = assert_raises Trailblazer::Activity::Circuit::IllegalSignalError do
assert_invoke Memo::Activity::Create, seq: "[:check_params, :handle_errors]", check_params: false, terminus: :failure
end

assert_equal exception.message.split("\n")[1][0..82], %(\e[31mUnrecognized Signal `#<Trailblazer::Activity::End semantic=:invalid>` returned)
end
end

class Strict_SubprocessDocsTest < Minitest::Spec
Memo = Class.new

module Memo::Activity
class Validate < Trailblazer::Activity::Railway
step :check_params,
Output(:failure) => End(:invalid)
step :text_present?
#~meths
include T.def_steps(:check_params, :text_present?)
#~meths end
end
end

module Memo::Activity
class Create < Trailblazer::Activity::Railway
step Subprocess(Validate, strict: true) # no wiring of {:invalid} terminus.
step :save
left :handle_errors
step :notify
#~meths
include T.def_steps(:validate, :save, :handle_errors, :notify)
#~meths end
end
end

it "raises {IllegalSignalError} at runtime when not connected" do
skip "see https://github.com/trailblazer/trailblazer-activity-dsl-linear/issues/59"

assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :save, :notify]"
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :save, :handle_errors]", save: false, terminus: :failure
assert_invoke Memo::Activity::Create, seq: "[:check_params, :text_present?, :handle_errors]", text_present?: false, terminus: :failure
# exception = assert_raises Trailblazer::Activity::Circuit::IllegalSignalError do
assert_invoke Memo::Activity::Create, seq: "[:check_params, :handle_errors]", check_params: false, terminus: :failure
# end

# assert_equal exception.message.split("\n")[1][0..82], %(\e[31mUnrecognized Signal `#<Trailblazer::Activity::End semantic=:invalid>` returned)
end
end

class SubprocessTest < Minitest::Spec


Expand Down

0 comments on commit 5886121

Please sign in to comment.