Modeling the Circuit Breaker: The Test Module
Explore modeling a circuit breaker using state machine properties in PropEr with Elixir. Understand how to define preconditions, update state after commands, and validate postconditions to create robust, reliable tests for real-world stateful systems.
We'll cover the following...
We'll cover the following...
The preconditions
Let’s start off by taking a look at the preconditions.
### Picks whether a command should be valid
def precondition(:unregistered, :ok, _, {:call, _, call, _}) do
call == :success
end
def precondition(:ok, to, %{errors: n, limit: l}, {:call, _, ...