mirror of
https://github.com/plashchynski/crono.git
synced 2026-03-29 05:42:02 +02:00
Add Job#healthy
This commit is contained in:
@@ -21,11 +21,12 @@ describe Crono::Job do
|
||||
end
|
||||
|
||||
describe "#perform" do
|
||||
after { job.send(:model).destroy }
|
||||
|
||||
it "should run performer in separate thread" do
|
||||
expect(job).to receive(:save)
|
||||
thread = job.perform.join
|
||||
expect(thread).to be_stop
|
||||
job.send(:model).destroy
|
||||
end
|
||||
|
||||
it "should save performin errors to log" do
|
||||
@@ -34,6 +35,16 @@ describe Crono::Job do
|
||||
saved_log = Crono::CronoJob.find_by(job_id: failing_job.job_id).log
|
||||
expect(saved_log).to include "Some error"
|
||||
end
|
||||
|
||||
it "should set Job#healthy to true if perform ok" do
|
||||
thread = job.perform.join
|
||||
expect(job.healthy).to be true
|
||||
end
|
||||
|
||||
it "should set Job#healthy to false if perform with error" do
|
||||
thread = failing_job.perform.join
|
||||
expect(failing_job.healthy).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#description" do
|
||||
@@ -51,9 +62,11 @@ describe Crono::Job do
|
||||
|
||||
it "should update saved job" do
|
||||
job.last_performed_at = Time.now
|
||||
job.healthy = true
|
||||
job.save
|
||||
@crono_job = Crono::CronoJob.find_by(job_id: job.job_id)
|
||||
expect(@crono_job.last_performed_at.utc.to_s).to be_eql job.last_performed_at.utc.to_s
|
||||
expect(@crono_job.healthy).to be true
|
||||
end
|
||||
|
||||
it "should save and truncate job log" do
|
||||
|
||||
@@ -49,7 +49,7 @@ describe Crono::Period do
|
||||
time = 10.minutes.from_now
|
||||
at = {hour: time.hour, min: time.min}
|
||||
@period = Crono::Period.new(2.day, at: at)
|
||||
expect(@period.next).to be_eql(Time.now.change(at))
|
||||
expect(@period.next.utc.to_s).to be_eql(Time.now.change(at).utc.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user