test/dirmon_job_test.rb in rocketjob-2.1.3 vs test/dirmon_job_test.rb in rocketjob-3.0.0.alpha
- old
+ new
@@ -15,11 +15,10 @@
@directory = '/tmp/directory'
@archive_directory = '/tmp/archive_directory'
@entry = RocketJob::DirmonEntry.new(
pattern: "#{@directory}/abc/*",
job_class_name: 'DirmonJobTest::DirmonTestJob',
- arguments: [{input: 'yes'}],
properties: {priority: 23},
archive_directory: @archive_directory
)
FileUtils.makedirs("#{@directory}/abc")
FileUtils.makedirs(@archive_directory)
@@ -162,11 +161,11 @@
RocketJob::Jobs::DirmonJob.stub_any_instance(:check_directories, new_file_names) do
@dirmon_job.perform_now
end
assert @dirmon_job.completed?, @dirmon_job.status.inspect
# Job must destroy on complete
- refute RocketJob::Jobs::DirmonJob.find(@dirmon_job.id)
+ assert_equal 0, RocketJob::Jobs::DirmonJob.where(id: @dirmon_job.id).count, -> { RocketJob::Jobs::DirmonJob.all.to_a.ai }
# Must have enqueued another instance to run in the future
assert_equal 1, RocketJob::Jobs::DirmonJob.count
assert new_dirmon_job = RocketJob::Jobs::DirmonJob.last
refute_equal @dirmon_job.id.to_s, new_dirmon_job.id.to_s
@@ -189,20 +188,21 @@
RocketJob::Jobs::DirmonJob.stub_any_instance(:check_directories, -> { raise RuntimeError.new('Oh no') }) do
assert_raises RuntimeError do
dirmon_job.perform_now
end
end
+ dirmon_job.save!
assert dirmon_job.aborted?, dirmon_job.status.ai
assert_equal 'RuntimeError', dirmon_job.exception.class_name, dirmon_job.exception.attributes
assert_equal 'Oh no', dirmon_job.exception.message, dirmon_job.exception.attributes
# Must have enqueued another instance to run in the future
- assert_equal 2, RocketJob::Jobs::DirmonJob.count, RocketJob::Jobs::DirmonJob.to_a
- assert new_dirmon_job = RocketJob::Jobs::DirmonJob.last
+ assert_equal 2, RocketJob::Jobs::DirmonJob.count, -> { RocketJob::Jobs::DirmonJob.all.ai }
+ assert new_dirmon_job = RocketJob::Jobs::DirmonJob.queued.first
assert new_dirmon_job.run_at
- assert_equal 11, new_dirmon_job.priority
+ assert_equal 11, new_dirmon_job.priority, -> { new_dirmon_job.attributes.ai }
assert_equal 30, new_dirmon_job.check_seconds
- assert new_dirmon_job.queued?
+ assert new_dirmon_job.queued?, new_dirmon_job.state
new_dirmon_job.destroy
end
end