Skip to content

Commit

Permalink
Execution Hanging Detection
Browse files Browse the repository at this point in the history
Increasing code coverage.

Signed-off-by: Rodrigo Nardi <[email protected]>
  • Loading branch information
RodrigoMNardi committed Oct 4, 2024
1 parent 5235435 commit caeaf16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/models/check_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ def execution_started?
end

def last_job_updated_at_timer
ci_jobs.max_by(&:updated_at).to_s.updated_at
ci_jobs.max_by(&:updated_at)&.updated_at
end
end
16 changes: 12 additions & 4 deletions spec/lib/models/check_suite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@
end
end

context '#last_job_updated_at_timer?' do
let(:ci_job) { create(:ci_job, updated_at: nil) }
context '#last_job_updated_at_timer? -> success' do
let(:ci_job) { create(:ci_job) }
let(:check_suite) { create(:check_suite, ci_jobs: [ci_job]) }
let(:check_suite_running) { create(:check_suite, :with_in_progress) }

it 'returns false' do
expect(check_suite_running.last_job_updated_at_timer).not_to be_nil
expect(check_suite.last_job_updated_at_timer).not_to be_nil
end
end

context '#last_job_updated_at_timer? -> error' do
let(:ci_job) { create(:ci_job, updated_at: nil) }
let(:check_suite) { create(:check_suite, ci_jobs: []) }

it 'returns false' do
expect(check_suite.last_job_updated_at_timer).to be_nil
end
end
end

0 comments on commit caeaf16

Please sign in to comment.