diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-23 13:05:41 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-23 13:05:41 +0100 |
commit | 627b4833c58b7bd9ffc852d4c76175366ab4f23b (patch) | |
tree | f0ea88d9a4cdb85b35d1ff45d92cd7a9b4a5d359 /spec/migrations | |
parent | 9ab50c86a9cc62f924509265886ce89d5ac47584 (diff) | |
download | gitlab-ce-627b4833c58b7bd9ffc852d4c76175366ab4f23b.tar.gz |
Add test case for scheduling runners tokens migration
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/schedule_runners_token_encryption_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/migrations/schedule_runners_token_encryption_spec.rb b/spec/migrations/schedule_runners_token_encryption_spec.rb new file mode 100644 index 00000000000..728220d0a7f --- /dev/null +++ b/spec/migrations/schedule_runners_token_encryption_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20181121111200_schedule_runners_token_encryption') + +describe ScheduleRunnersTokenEncryption, :migration do + let(:settings) { table(:application_settings) } + let(:namespaces) { table(:namespaces) } + let(:projects) { table(:projects) } + let(:runners) { table(:ci_runners) } + + before do + stub_const("#{described_class.name}::BATCH_SIZE", 1) + + settings.create!(id: 1, runners_registration_token: 'plain-text-token1') + namespaces.create!(id: 11, name: 'gitlab', path: 'gitlab-org', runners_token: 'my-token1') + namespaces.create!(id: 12, name: 'gitlab', path: 'gitlab-org', runners_token: 'my-token2') + projects.create!(id: 111, namespace_id: 11, name: 'gitlab', path: 'gitlab-ce', runners_token: 'my-token1') + projects.create!(id: 114, namespace_id: 11, name: 'gitlab', path: 'gitlab-ce', runners_token: 'my-token2') + runners.create!(id: 201, runner_type: 1, token: 'plain-text-token1') + runners.create!(id: 202, runner_type: 1, token: 'plain-text-token2') + end + + it 'schedules runners token encryption migration for multiple resources' do + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(BackgroundMigrationWorker.jobs.size).to eq 7 + end + end + end +end |