diff options
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/20201110161542_cleanup_transfered_projects_shared_runners_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/migrations/20201110161542_cleanup_transfered_projects_shared_runners_spec.rb b/spec/migrations/20201110161542_cleanup_transfered_projects_shared_runners_spec.rb new file mode 100644 index 00000000000..8563114c9f9 --- /dev/null +++ b/spec/migrations/20201110161542_cleanup_transfered_projects_shared_runners_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20201110161542_cleanup_transfered_projects_shared_runners.rb') + +RSpec.describe CleanupTransferedProjectsSharedRunners, :sidekiq, schema: 20201110161542 do + let(:namespaces) { table(:namespaces) } + let(:migration) { described_class.new } + let(:batch_interval) { described_class::INTERVAL } + + let!(:namespace_1) { namespaces.create!(name: 'foo', path: 'foo') } + let!(:namespace_2) { namespaces.create!(name: 'bar', path: 'bar') } + let!(:namespace_3) { namespaces.create!(name: 'baz', path: 'baz') } + + describe '#up' do + before do + stub_const("#{described_class}::BATCH_SIZE", 2) + end + + it 'schedules ResetSharedRunnersForTransferredProjects background jobs' do + Sidekiq::Testing.fake! do + freeze_time do + migration.up + + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + expect(described_class::MIGRATION).to be_scheduled_delayed_migration(batch_interval, namespace_1.id, namespace_2.id) + expect(described_class::MIGRATION).to be_scheduled_delayed_migration(batch_interval * 2, namespace_3.id, namespace_3.id) + end + end + end + end +end |