diff --git a/lib/plines/job_batch.rb b/lib/plines/job_batch.rb index 7148f5e..1266440 100644 --- a/lib/plines/job_batch.rb +++ b/lib/plines/job_batch.rb @@ -132,7 +132,7 @@ def complete_job(qless_job) end def complete? - _complete?(pending_job_jids.length, completed_job_jids.length) + !!completed_at end def resolve_external_dependency(dep_name) @@ -319,10 +319,6 @@ def update_external_dependency(dep_name, meth, jids) end end - def _complete?(pending_size, complete_size) - pending_size == 0 && complete_size > 0 - end - def time_from(meta_entry) date_string = meta[meta_entry] Time.iso8601(date_string) if date_string diff --git a/spec/unit/plines/job_batch_spec.rb b/spec/unit/plines/job_batch_spec.rb index 9c5a7c7..a2732af 100644 --- a/spec/unit/plines/job_batch_spec.rb +++ b/spec/unit/plines/job_batch_spec.rb @@ -501,23 +501,16 @@ def create_batch_with_job end describe "#complete?" do - it 'returns false when there are no pending or completed jobs' do + it 'returns true if the job batch has a completed_at timestamp' do batch = JobBatch.create(qless, pipeline_module, "foo", {}) - expect(batch).not_to be_complete + batch.meta['completed_at'] = Time.now.getutc.iso8601 + expect(batch).to be_complete end - it 'returns false when there are pending jobs and completed jobs' do + it 'returns false if it lacks a completed_at timestamp' do batch = JobBatch.create(qless, pipeline_module, "foo", {}) - batch.pending_job_jids << "a" - batch.completed_job_jids << "b" expect(batch).not_to be_complete end - - it 'returns true when there are only completed jobs' do - batch = JobBatch.create(qless, pipeline_module, "foo", {}) - batch.completed_job_jids << "b" - expect(batch).to be_complete - end end describe "#pending_qless_jobs" do @@ -742,7 +735,7 @@ def update_dependency(batch, name) end it 'returns true for a complete job batch' do - batch.completed_job_jids << "a" + batch.meta['completed_at'] = Time.now.getutc.iso8601 expect(batch.in_terminal_state?).to be_true end