summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-10-21 11:29:47 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-11-03 13:12:16 +0100
commit8d2758e02d634fd8518893f39dcc3359284e890f (patch)
tree8a1d0dada6d607aba39d02f4b3ea2824e6774162 /spec/workers
parentfb2f8be4d7cddc01471b58334c33ecdee4d0b887 (diff)
downloadgitlab-ce-8d2758e02d634fd8518893f39dcc3359284e890f.tar.gz
Cleanup stuck CI builds dailydrop-old-builds
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/stuck_ci_builds_worker_spec.rb44
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