summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/background_migration_spec.rb
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2018-12-19 16:34:34 +0800
committerMark Chao <mchao@gitlab.com>2019-01-08 15:19:45 +0800
commit3ab5af14a2e2ea9668b611f7b4bcf56b9f722161 (patch)
tree5b9cec865827f679042d39fac718beaf85367e14 /spec/lib/gitlab/background_migration_spec.rb
parent1d2ef4c6557846eb531f4d0e80cf43dea99b037b (diff)
downloadgitlab-ce-3ab5af14a2e2ea9668b611f7b4bcf56b9f722161.tar.gz
Check if specific type of background migration are done
Useful for checking progress.
Diffstat (limited to 'spec/lib/gitlab/background_migration_spec.rb')
-rw-r--r--spec/lib/gitlab/background_migration_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb
index 4ad69aeba43..8a83b76fd94 100644
--- a/spec/lib/gitlab/background_migration_spec.rb
+++ b/spec/lib/gitlab/background_migration_spec.rb
@@ -119,4 +119,48 @@ describe Gitlab::BackgroundMigration do
described_class.perform('Foo', [10, 20])
end
end
+
+ describe '.exists?' do
+ context 'when there are enqueued jobs present' do
+ let(:queue) do
+ [double(args: ['Foo', [10, 20]], queue: described_class.queue)]
+ end
+
+ before do
+ allow(Sidekiq::Queue).to receive(:new)
+ .with(described_class.queue)
+ .and_return(queue)
+ end
+
+ it 'returns true if specific job exists' do
+ expect(described_class.exists?('Foo')).to eq(true)
+ end
+
+ it 'returns false if specific job does not exist' do
+ expect(described_class.exists?('Bar')).to eq(false)
+ end
+ end
+
+ context 'when there are scheduled jobs present', :sidekiq, :redis do
+ before do
+ Sidekiq::Testing.disable! do
+ BackgroundMigrationWorker.perform_in(10.minutes, 'Foo')
+
+ expect(Sidekiq::ScheduledSet.new).to be_one
+ end
+ end
+
+ after do
+ Sidekiq::ScheduledSet.new.clear
+ end
+
+ it 'returns true if specific job exists' do
+ expect(described_class.exists?('Foo')).to eq(true)
+ end
+
+ it 'returns false if specific job does not exist' do
+ expect(described_class.exists?('Bar')).to eq(false)
+ end
+ end
+ end
end