add more specs
This commit is contained in:
parent
cc088956bc
commit
e11c83341c
|
@ -58,6 +58,14 @@ describe Scheduler::Manager do
|
||||||
Scheduler::Manager.new(DiscourseRedis.new, enable_stats: false)
|
Scheduler::Manager.new(DiscourseRedis.new, enable_stats: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it 'can disable stats' do
|
||||||
|
manager = Scheduler::Manager.new(DiscourseRedis.new, enable_stats: false)
|
||||||
|
expect(manager.enable_stats).to eq(false)
|
||||||
|
|
||||||
|
manager = Scheduler::Manager.new(DiscourseRedis.new)
|
||||||
|
expect(manager.enable_stats).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
$redis.del manager.class.lock_key
|
$redis.del manager.class.lock_key
|
||||||
$redis.del manager.class.queue_key
|
$redis.del manager.class.queue_key
|
||||||
|
@ -140,6 +148,7 @@ describe Scheduler::Manager do
|
||||||
Testing::RandomJob.runs = 0
|
Testing::RandomJob.runs = 0
|
||||||
|
|
||||||
info = manager.schedule_info(Testing::RandomJob)
|
info = manager.schedule_info(Testing::RandomJob)
|
||||||
|
manager.enable_stats = true
|
||||||
info.next_run = Time.now.to_i - 1
|
info.next_run = Time.now.to_i - 1
|
||||||
info.write!
|
info.write!
|
||||||
|
|
||||||
|
@ -151,11 +160,13 @@ describe Scheduler::Manager do
|
||||||
expect(stat).to be_present
|
expect(stat).to be_present
|
||||||
expect(stat.duration_ms).to be > 0
|
expect(stat.duration_ms).to be > 0
|
||||||
expect(stat.success).to be true
|
expect(stat.success).to be true
|
||||||
|
SchedulerStat.destroy_all
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should log when jobs start running' do
|
it 'should log when jobs start running' do
|
||||||
info = manager.schedule_info(Testing::SuperLongJob)
|
info = manager.schedule_info(Testing::SuperLongJob)
|
||||||
|
manager.enable_stats = true
|
||||||
info.next_run = Time.now.to_i - 1
|
info.next_run = Time.now.to_i - 1
|
||||||
info.write!
|
info.write!
|
||||||
|
|
||||||
|
@ -164,6 +175,7 @@ describe Scheduler::Manager do
|
||||||
|
|
||||||
stat = SchedulerStat.first
|
stat = SchedulerStat.first
|
||||||
expect(stat).to be_present
|
expect(stat).to be_present
|
||||||
|
SchedulerStat.destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should only run pending job once' do
|
it 'should only run pending job once' do
|
||||||
|
|
Loading…
Reference in New Issue