diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 18:08:19 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 18:08:19 +0000 |
commit | a8de96bff51846e160b76506dc0ca0fe6f767f64 (patch) | |
tree | 1036f1ca75aba492eaaa3439c84a3109b4684896 /spec/tasks | |
parent | afe2b984524ae4b0c8a0636db7ec5b2c452f0734 (diff) | |
download | gitlab-ce-a8de96bff51846e160b76506dc0ca0fe6f767f64.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/gitlab/import_export/export_rake_spec.rb | 37 | ||||
-rw-r--r-- | spec/tasks/gitlab/import_export/import_rake_spec.rb | 91 |
2 files changed, 0 insertions, 128 deletions
diff --git a/spec/tasks/gitlab/import_export/export_rake_spec.rb b/spec/tasks/gitlab/import_export/export_rake_spec.rb deleted file mode 100644 index b665b46fe1c..00000000000 --- a/spec/tasks/gitlab/import_export/export_rake_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require 'rake_helper' - -describe 'gitlab:import_export:export rake task' do - let(:username) { 'root' } - let(:namespace_path) { username } - let!(:user) { create(:user, username: username) } - let(:measurement_enabled) { false } - let(:task_params) { [username, namespace_path, project_name, archive_path, measurement_enabled] } - - before do - Rake.application.rake_require('tasks/gitlab/import_export/export') - end - - subject { run_rake_task('gitlab:import_export:export', task_params) } - - context 'when project is found' do - let(:project) { create(:project, creator: user, namespace: user.namespace) } - let(:project_name) { project.name } - let(:archive_path) { 'spec/fixtures/gitlab/import_export/test_project_export.tar.gz' } - - around do |example| - example.run - ensure - File.delete(archive_path) - end - - it 'performs project export successfully' do - expect { subject }.to output(/Done!/).to_stdout - - expect(File).to exist(archive_path) - end - - it_behaves_like 'measurable' - end -end diff --git a/spec/tasks/gitlab/import_export/import_rake_spec.rb b/spec/tasks/gitlab/import_export/import_rake_spec.rb deleted file mode 100644 index 3e0bf2d0832..00000000000 --- a/spec/tasks/gitlab/import_export/import_rake_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -# frozen_string_literal: true - -require 'rake_helper' - -describe 'gitlab:import_export:import rake task' do - let(:username) { 'root' } - let(:namespace_path) { username } - let!(:user) { create(:user, username: username) } - let(:measurement_enabled) { false } - let(:task_params) { [username, namespace_path, project_name, archive_path, measurement_enabled] } - let(:project) { Project.find_by_full_path("#{namespace_path}/#{project_name}") } - - before do - Rake.application.rake_require('tasks/gitlab/import_export/import') - allow(Settings.uploads.object_store).to receive(:[]=).and_call_original - allow_any_instance_of(GitlabProjectImport).to receive(:exit) - .and_raise(RuntimeError, 'exit not handled') - end - - around do |example| - old_direct_upload_setting = Settings.uploads.object_store['direct_upload'] - old_background_upload_setting = Settings.uploads.object_store['background_upload'] - - Settings.uploads.object_store['direct_upload'] = true - Settings.uploads.object_store['background_upload'] = true - - example.run - - Settings.uploads.object_store['direct_upload'] = old_direct_upload_setting - Settings.uploads.object_store['background_upload'] = old_background_upload_setting - end - - subject { run_rake_task('gitlab:import_export:import', task_params) } - - context 'when project import is valid' do - let(:project_name) { 'import_rake_test_project' } - let(:archive_path) { 'spec/fixtures/gitlab/import_export/lightweight_project_export.tar.gz' } - - it 'performs project import successfully' do - expect { subject }.to output(/Done!/).to_stdout - expect { subject }.not_to raise_error - - expect(project.merge_requests.count).to be > 0 - expect(project.issues.count).to be > 0 - expect(project.milestones.count).to be > 0 - expect(project.import_state.status).to eq('finished') - end - - it 'disables direct & background upload only during project creation' do - expect_next_instance_of(Projects::GitlabProjectsImportService) do |service| - expect(service).to receive(:execute).and_wrap_original do |m| - expect(Settings.uploads.object_store['background_upload']).to eq(false) - expect(Settings.uploads.object_store['direct_upload']).to eq(false) - - m.call - end - end - - expect_next_instance_of(GitlabProjectImport) do |importer| - expect(importer).to receive(:execute_sidekiq_job).and_wrap_original do |m| - expect(Settings.uploads.object_store['background_upload']).to eq(true) - expect(Settings.uploads.object_store['direct_upload']).to eq(true) - expect(Settings.uploads.object_store).not_to receive(:[]=).with('backgroud_upload', false) - expect(Settings.uploads.object_store).not_to receive(:[]=).with('direct_upload', false) - - m.call - end - end - - subject - end - - it_behaves_like 'measurable' - end - - context 'when project import is invalid' do - let(:project_name) { 'import_rake_invalid_test_project' } - let(:archive_path) { 'spec/fixtures/gitlab/import_export/corrupted_project_export.tar.gz' } - let(:not_imported_message) { /Total number of not imported relations: 1/ } - let(:error) { /Validation failed: Notes is invalid/ } - - it 'performs project import successfully' do - expect { subject }.to output(not_imported_message).to_stdout - expect { subject }.not_to raise_error - - expect(project.merge_requests).to be_empty - expect(project.import_state.last_error).to be_nil - expect(project.import_state.status).to eq('finished') - end - end -end |