spec/unit/reaper_spec.rb in heroku_hatchet-8.0.0 vs spec/unit/reaper_spec.rb in heroku_hatchet-8.0.1
- old
+ new
@@ -16,22 +16,22 @@
expect(reaper.instance_variable_get("@destroy_with_log_count")).to eq(1)
end
describe "cycle" do
- it "does not delete anything if under the limit" do
+ it "does not delete anything if no old apps" do
reaper = Hatchet::Reaper.new(api_rate_limit: Object.new, hatchet_app_limit: 1, io: StringIO.new)
def reaper.get_heroku_apps
@called_get_heroku_apps = true
@mock_apps ||= [{"name" => "hatchet-t-foo", "id" => 1, "maintenance" => true, "created_at" => Time.now.to_s}]
end
def reaper.check_get_heroku_apps_called; @called_get_heroku_apps ; end
def reaper.reap_once; raise "should not be called"; end
- reaper.clean_old_or_sleep
+ reaper.destroy_older_apps
expect(reaper.check_get_heroku_apps_called).to be_truthy
end
it "deletes an old app that is past TLL" do
@@ -44,22 +44,22 @@
def reaper.destroy_with_log(name: , id: , reason: )
@reaper_destroy_called_with = {"name" => name, "id" => id}
end
def reaper.destroy_called_with; @reaper_destroy_called_with; end
- reaper.clean_old_or_sleep
+ reaper.destroy_older_apps
expect(reaper.destroy_called_with).to eq({"name" => "hatchet-t-foo", "id" => 1})
end
it "sleeps, refreshes app list, and tries again when an old app is not past TTL" do
warning = StringIO.new
reaper = Hatchet::Reaper.new(
+ io: warning,
+ initial_sleep: 0,
api_rate_limit: Object.new,
hatchet_app_limit: 0,
- initial_sleep: 0,
- io: warning
)
def reaper.get_heroku_apps
now = DateTime.now.new_offset(0)
@mock_apps ||= [{"name" => "hatchet-t-foo", "id" => 1, "maintenance" => false, "created_at" => now.to_s }]
@@ -72,10 +72,11 @@
@_slept_for = val
end
def reaper.get_slept_for_val; @_slept_for; end
- reaper.clean_old_or_sleep
+ reaper.destroy_older_apps
+ reaper.sleep_if_over_limit(reason: "test")
expect(reaper.get_slept_for_val).to eq(0)
expect(reaper.destroy_called_with).to eq(nil)
expect(warning.string).to include("WARNING: Hatchet app limit reached (1/0)")