diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2015-11-03 16:56:43 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2015-11-03 16:56:43 +0300 |
commit | 77ef4855e0b69fa9e7f5501b64d08d3fc0fe1205 (patch) | |
tree | 1a373db3309564b59fa85ce9d7615c5d79b7a738 /spec | |
parent | b12e17ff5574dd960550a7a4cdf92f22a6e67fb1 (diff) | |
parent | 8d2758e02d634fd8518893f39dcc3359284e890f (diff) |
Merge branch 'drop-old-builds' into 'master'
Cleanup stuck CI builds
Fixes #3143
/cc @dzaporozhets @jacobvosmaer
See merge request !1655
Diffstat (limited to 'spec')
-rw-r--r-- | spec/workers/stuck_ci_builds_worker_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/workers/stuck_ci_builds_worker_spec.rb b/spec/workers/stuck_ci_builds_worker_spec.rb new file mode 100644 index 00000000000..f9d87d97014 --- /dev/null +++ b/spec/workers/stuck_ci_builds_worker_spec.rb @@ -0,0 +1,44 @@ +require "spec_helper" + +describe StuckCiBuildsWorker do + let!(:build) { create :ci_build } + + subject do + build.reload + build.status + end + + %w(pending running).each do |status| + context "#{status} build" do + before do + build.update!(status: status) + end + + it 'gets dropped if it was updated over 2 days ago' do + build.update!(updated_at: 2.day.ago) + StuckCiBuildsWorker.new.perform + is_expected.to eq('failed') + end + + it "is still #{status}" do + build.update!(updated_at: 1.minute.ago) + StuckCiBuildsWorker.new.perform + is_expected.to eq(status) + end + end + end + + %w(success failed canceled).each do |status| + context "#{status} build" do + before do + build.update!(status: status) + end + + it "is still #{status}" do + build.update!(updated_at: 2.day.ago) + StuckCiBuildsWorker.new.perform + is_expected.to eq(status) + end + end + end +end |