Sha256: 7c043e1f27a5e6cfd0ba1956746db4c8ea5f7c86a41d981df22cb2e3478ed907
Contents?: true
Size: 1.19 KB
Versions: 5
Compression:
Stored size: 1.19 KB
Contents
require 'test_helper' module Cron class TrimCronServersTest < ActiveSupport::TestCase context 'Execute job not deleting servers' do should 'not throw exceptions if no servers ' do assert_nothing_raised { Cron::TrimCronServers.perform_now } end should 'not delete any servers due to last updated' do 10.times.each { |n| Cron::Server.create!(host_name: "ip-#{n}", pid: n.to_s).set(last_check_in_at: Time.now.utc) } assert_equal 10, Cron::Server.all.count assert_no_difference 'Cron::Server.all.count' do assert_nothing_raised { Cron::TrimCronServers.perform_now } end end end context 'Execute jobs deleting servers' do should 'delete five server logs' do 5.times.each { |n| Cron::Server.create!(host_name: "ip-#{n}", pid: n.to_s).set(last_check_in_at: Time.now.utc) } 5.times.each { |n| Cron::Server.create!(host_name: "ip-#{n}", pid: (100+n).to_s).set(last_check_in_at: 1.hour.ago.utc) } assert_equal 10, Cron::Server.all.count assert_difference 'Cron::Server.all.count', -5 do assert_nothing_raised { Cron::TrimCronServers.perform_now } end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems