Modeling the Circuit Breaker: The Test Module
Complete the test module with the stateful generators and take a look at the completed test suite.
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, _, :err, _}) do
(to == :tripped and n + 1 == l) or (to == :ok and n + 1 !=
...