diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb b/spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb index e1e75be2494..c1eccafa987 100644 --- a/spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/container_repositories_shared_examples.rb @@ -116,3 +116,93 @@ RSpec.shared_examples 'not hitting graphql network errors with the container reg expect_graphql_errors_to_be_empty end end + +RSpec.shared_examples 'reconciling migration_state' do + shared_examples 'enforcing states coherence to' do |expected_migration_state| + it 'leaves the repository in the expected migration_state' do + expect(repository.gitlab_api_client).not_to receive(:pre_import_repository) + expect(repository.gitlab_api_client).not_to receive(:import_repository) + + subject + + expect(repository.reload.migration_state).to eq(expected_migration_state) + end + end + + shared_examples 'retrying the pre_import' do + it 'retries the pre_import' do + expect(repository).to receive(:migration_pre_import).and_return(:ok) + + expect { subject }.to change { repository.reload.migration_state }.to('pre_importing') + end + end + + shared_examples 'retrying the import' do + it 'retries the import' do + expect(repository).to receive(:migration_import).and_return(:ok) + + expect { subject }.to change { repository.reload.migration_state }.to('importing') + end + end + + context 'native response' do + let(:status) { 'native' } + + it 'finishes the import' do + expect { subject } + .to change { repository.reload.migration_state }.to('import_done') + .and change { repository.reload.migration_skipped_reason }.to('native_import') + end + end + + context 'import_in_progress response' do + let(:status) { 'import_in_progress' } + + it_behaves_like 'enforcing states coherence to', 'importing' + end + + context 'import_complete response' do + let(:status) { 'import_complete' } + + it 'finishes the import' do + expect { subject }.to change { repository.reload.migration_state }.to('import_done') + end + end + + context 'import_failed response' do + let(:status) { 'import_failed' } + + it_behaves_like 'retrying the import' + end + + context 'pre_import_in_progress response' do + let(:status) { 'pre_import_in_progress' } + + it_behaves_like 'enforcing states coherence to', 'pre_importing' + end + + context 'pre_import_complete response' do + let(:status) { 'pre_import_complete' } + + it 'finishes the pre_import and starts the import' do + expect(repository).to receive(:finish_pre_import).and_call_original + expect(repository).to receive(:migration_import).and_return(:ok) + + expect { subject }.to change { repository.reload.migration_state }.to('importing') + end + end + + context 'pre_import_failed response' do + let(:status) { 'pre_import_failed' } + + it_behaves_like 'retrying the pre_import' + end + + %w[pre_import_canceled import_canceled].each do |canceled_status| + context "#{canceled_status} response" do + let(:status) { canceled_status } + + it_behaves_like 'enforcing states coherence to', 'import_skipped' + end + end +end |