2022-10-07 10:04:02 +13:00
|
|
|
defmodule Ash.Test.Flow.Flows.Halting do
|
|
|
|
@moduledoc false
|
|
|
|
use Ash.Flow
|
|
|
|
|
|
|
|
flow do
|
|
|
|
argument :on_step, :atom do
|
2023-06-06 08:50:11 +12:00
|
|
|
constraints(one_of: [:a, :b, :c])
|
2022-10-07 10:04:02 +13:00
|
|
|
end
|
|
|
|
|
2023-06-06 08:50:11 +12:00
|
|
|
returns(:c)
|
2022-10-07 10:04:02 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
steps do
|
|
|
|
custom :a, Ash.Test.Flow.Steps.SimpleReturn do
|
2023-06-06 08:50:11 +12:00
|
|
|
input(%{return: "a"})
|
|
|
|
halt_if(expr(not (^arg(:on_step) == :a || false)))
|
|
|
|
halt_reason(:not_on_step_a)
|
2022-10-07 10:04:02 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
custom :b, Ash.Test.Flow.Steps.SimpleReturn do
|
2023-06-06 08:50:11 +12:00
|
|
|
input(%{return: "b"})
|
|
|
|
halt_if(expr(not (^arg(:on_step) == :b || false)))
|
|
|
|
wait_for(result(:a))
|
|
|
|
halt_reason(:not_on_step_b)
|
2022-10-07 10:04:02 +13:00
|
|
|
end
|
|
|
|
|
|
|
|
custom :c, Ash.Test.Flow.Steps.SimpleReturn do
|
2023-06-06 08:50:11 +12:00
|
|
|
input(%{return: "c"})
|
|
|
|
halt_if(expr(not (^arg(:on_step) == :c || false)))
|
|
|
|
wait_for(result(:b))
|
|
|
|
halt_reason(:not_on_step_c)
|
2022-10-07 10:04:02 +13:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|