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

migration_shared_examples.rb « uploads « gitlab « tasks « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b37a8059574b09cf8d487dbc2facd198410dbb15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

# Expects the calling spec to define:
# - uploader_class
# - model_class
# - mounted_as
RSpec.shared_examples 'enqueue upload migration jobs in batch' do |batch:|
  def run(task)
    args = [uploader_class.to_s, model_class.to_s, mounted_as].compact
    run_rake_task(task, *args)
  end

  it 'migrates local storage to remote object storage' do
    expect(ObjectStorage::MigrateUploadsWorker)
      .to receive(:perform_async).exactly(batch).times
      .and_return("A fake job.")

    run('gitlab:uploads:migrate')
  end

  it 'migrates remote object storage to local storage' do
    expect(Upload).to receive(:where).exactly(batch + 1).times { Upload.all }
    expect(ObjectStorage::MigrateUploadsWorker)
      .to receive(:perform_async)
      .with(anything, model_class.name, mounted_as, ObjectStorage::Store::LOCAL)
      .exactly(batch).times
      .and_return("A fake job.")

    run('gitlab:uploads:migrate_to_local')
  end
end