Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/migrations/20220420135946_update_batched_background_migration_arguments_spec.rb')
-rw-r--r--spec/migrations/20220420135946_update_batched_background_migration_arguments_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/migrations/20220420135946_update_batched_background_migration_arguments_spec.rb b/spec/migrations/20220420135946_update_batched_background_migration_arguments_spec.rb
new file mode 100644
index 00000000000..6dbee483e15
--- /dev/null
+++ b/spec/migrations/20220420135946_update_batched_background_migration_arguments_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require_migration!
+
+RSpec.describe UpdateBatchedBackgroundMigrationArguments do
+ let(:batched_migrations) { table(:batched_background_migrations) }
+
+ before do
+ common_attributes = {
+ max_value: 10,
+ batch_size: 5,
+ sub_batch_size: 2,
+ interval: 2.minutes,
+ table_name: 'events',
+ column_name: 'id'
+ }
+
+ batched_migrations.create!(common_attributes.merge(job_class_name: 'Job1', job_arguments: '[]'))
+ batched_migrations.create!(common_attributes.merge(job_class_name: 'Job2', job_arguments: '["some_argument"]'))
+ batched_migrations.create!(common_attributes.merge(job_class_name: 'Job3', job_arguments: '[]'))
+ end
+
+ describe '#up' do
+ it 'updates batched migration arguments to have an empty jsonb array' do
+ expect { migrate! }
+ .to change { batched_migrations.where("job_arguments = '[]'").count }.from(0).to(2)
+ .and change { batched_migrations.where("job_arguments = '\"[]\"'").count }.from(2).to(0)
+ end
+ end
+
+ describe '#down' do
+ before do
+ migrate!
+ end
+
+ it 'reverts batched migration arguments to have the previous default' do
+ expect { schema_migrate_down! }
+ .to change { batched_migrations.where("job_arguments = '\"[]\"'").count }.from(0).to(2)
+ .and change { batched_migrations.where("job_arguments = '[]'").count }.from(2).to(0)
+ end
+ end
+end