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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-07 03:10:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-07 03:10:26 +0300
commit1e19d757e8a088e9d4aa67cc092fda87aba1cd35 (patch)
treeb183775b7355dae057ab0d2e5076df86cdc8a77d /spec/tasks
parentb04f912deb494b6dc0d0dba36776a5e53f622b43 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/ci_secure_files/migrate_rake_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/ci_secure_files/migrate_rake_spec.rb b/spec/tasks/gitlab/ci_secure_files/migrate_rake_spec.rb
new file mode 100644
index 00000000000..ed6b5914f3e
--- /dev/null
+++ b/spec/tasks/gitlab/ci_secure_files/migrate_rake_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+require 'rake_helper'
+
+RSpec.describe 'gitlab:ci_secure_files', feature_category: :mobile_devops do
+ let_it_be(:local_file) { create(:ci_secure_file) }
+
+ let(:logger) { instance_double(Logger) }
+ let(:helper) { double }
+
+ before(:all) do
+ Rake.application.rake_require 'tasks/gitlab/ci_secure_files/migrate'
+ end
+
+ before do
+ allow(Logger).to receive(:new).with($stdout).and_return(logger)
+ end
+
+ describe 'gitlab:ci_secure_files:migrate' do
+ subject { run_rake_task('gitlab:ci_secure_files:migrate') }
+
+ it 'invokes the migration helper to move files to object storage' do
+ expect(Gitlab::Ci::SecureFiles::MigrationHelper).to receive(:migrate_to_remote_storage).and_yield(local_file)
+ expect(logger).to receive(:info).with('Starting transfer of Secure Files to object storage')
+ expect(logger).to receive(:info).with(/Transferred Secure File ID #{local_file.id}/)
+
+ subject
+ end
+
+ context 'when an error is raised while migrating' do
+ let(:error_message) { 'Something went wrong' }
+
+ before do
+ allow(Gitlab::Ci::SecureFiles::MigrationHelper).to receive(:migrate_to_remote_storage).and_raise(StandardError,
+ error_message)
+ end
+
+ it 'logs the error' do
+ expect(logger).to receive(:info).with('Starting transfer of Secure Files to object storage')
+ expect(logger).to receive(:error).with("Failed to migrate: #{error_message}")
+
+ subject
+ end
+ end
+ end
+end