-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A public method to clear cached circuits in tests #173
Comments
Time permitting, I'll have this change merged in the next few days. Not sure if I'll keep the same method name or change it a bit. |
+1. I tried the code in the 2.0 upgrading doc when
|
I haven't run into circuitbox not resetting circuit's after a configuration change when circuits are accessed through I put together a small minitest suite using what's described in the upgrade guide and reset appears to be working. require 'minitest'
require 'circuitbox'
class CircuitboxResetTest < Minitest::Test
def setup
Circuitbox.configure do |config|
config.default_circuit_store = Circuitbox::MemoryStore.new
end
end
def test_circuit_one
runs = 0
5.times do
circuit_fail do
runs += 1
end
end
assert_equal 2, runs
end
def test_circuit_two
runs = 0
5.times do
circuit_fail do
runs += 1
end
end
assert_equal 2, runs
end
def circuit_fail
Circuitbox.circuit(:test, exceptions: [StandardError], volume_threshold: 2) do
yield
raise StandardError
end
end
end
Minitest.run I've run that a few times and haven't run into any failures. Once I remove the tests setup failures start to show up as the circuit state is being leaked across tests. If you're running into issues could you put something together that reproduces circuits not being reset? |
Thanks @matthewshafer. I went back and reviewed it, and your example test helped me uncover an issue where I wasn't calling the reset enough. |
Hi!
It would be great to have a public method where we can clear cached circuits to use before each test run.
Today, one test can open a circuit and then it can cause failures in many others that use the same circuit.
This gets in the way to find the real culprit.
What about turning the method
Circuitbox.clear_cached_circuits!
into a public one?The text was updated successfully, but these errors were encountered: