diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-01 18:10:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-01 18:10:53 +0300 |
commit | dff63567c3bdad66d092989f9bf85b6faa32da65 (patch) | |
tree | cde62e3a2ae15d435b345bbab09ac8b0ae09f3dc /spec/support/matchers | |
parent | 37ecd38c4e5a4df8d58283e8bdbb9d66f0c84494 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/matchers')
-rw-r--r-- | spec/support/matchers/background_migrations_matchers.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/spec/support/matchers/background_migrations_matchers.rb b/spec/support/matchers/background_migrations_matchers.rb index 0144a044f6c..08bbbcc7438 100644 --- a/spec/support/matchers/background_migrations_matchers.rb +++ b/spec/support/matchers/background_migrations_matchers.rb @@ -1,7 +1,17 @@ # frozen_string_literal: true +RSpec::Matchers.define :be_background_migration_with_arguments do |arguments| + define_method :matches? do |migration| + expect do + Gitlab::BackgroundMigration.perform(migration, arguments) + end.not_to raise_error + end +end + RSpec::Matchers.define :be_scheduled_delayed_migration do |delay, *expected| - match do |migration| + define_method :matches? do |migration| + expect(migration).to be_background_migration_with_arguments(expected) + BackgroundMigrationWorker.jobs.any? do |job| job['args'] == [migration, expected] && job['at'].to_i == (delay.to_i + Time.now.to_i) @@ -16,7 +26,9 @@ RSpec::Matchers.define :be_scheduled_delayed_migration do |delay, *expected| end RSpec::Matchers.define :be_scheduled_migration do |*expected| - match do |migration| + define_method :matches? do |migration| + expect(migration).to be_background_migration_with_arguments(expected) + BackgroundMigrationWorker.jobs.any? do |job| args = job['args'].size == 1 ? [BackgroundMigrationWorker.jobs[0]['args'][0], []] : job['args'] args == [migration, expected] @@ -29,7 +41,9 @@ RSpec::Matchers.define :be_scheduled_migration do |*expected| end RSpec::Matchers.define :be_scheduled_migration_with_multiple_args do |*expected| - match do |migration| + define_method :matches? do |migration| + expect(migration).to be_background_migration_with_arguments(expected) + BackgroundMigrationWorker.jobs.any? do |job| args = job['args'].size == 1 ? [BackgroundMigrationWorker.jobs[0]['args'][0], []] : job['args'] args[0] == migration && compare_args(args, expected) |