debian-mirror-gitlab/spec/migrations/backfill_snippet_repositories_spec.rb

45 lines
1 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-09-04 01:27:46 +05:30
require_migration!
2020-05-24 23:13:21 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe BackfillSnippetRepositories do
2020-05-24 23:13:21 +05:30
let(:users) { table(:users) }
let(:snippets) { table(:snippets) }
2021-02-22 17:27:13 +05:30
let(:user) { users.create!(id: 1, email: 'user@example.com', projects_limit: 10, username: 'test', name: 'Test', state: 'active') }
2020-05-24 23:13:21 +05:30
def create_snippet(id)
params = {
id: id,
type: 'PersonalSnippet',
author_id: user.id,
file_name: 'foo',
content: 'bar'
}
snippets.create!(params)
end
it 'correctly schedules background migrations' do
create_snippet(1)
create_snippet(2)
create_snippet(3)
stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do
2020-11-24 15:15:51 +05:30
freeze_time do
2020-05-24 23:13:21 +05:30
migrate!
expect(described_class::MIGRATION)
.to be_scheduled_delayed_migration(3.minutes, 1, 2)
expect(described_class::MIGRATION)
.to be_scheduled_delayed_migration(6.minutes, 3, 3)
expect(BackgroundMigrationWorker.jobs.size).to eq(2)
end
end
end
end