diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/migrations/20220420135946_update_batched_background_migration_arguments_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
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.rb | 44 |
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 |