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:
Diffstat (limited to 'spec/migrations/fill_file_store_ci_job_artifacts_spec.rb')
-rw-r--r--spec/migrations/fill_file_store_ci_job_artifacts_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/migrations/fill_file_store_ci_job_artifacts_spec.rb b/spec/migrations/fill_file_store_ci_job_artifacts_spec.rb
new file mode 100644
index 00000000000..5435a438824
--- /dev/null
+++ b/spec/migrations/fill_file_store_ci_job_artifacts_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'migrate', '20200513235532_fill_file_store_ci_job_artifacts.rb')
+
+describe FillFileStoreCiJobArtifacts do
+ let(:namespaces) { table(:namespaces) }
+ let(:projects) { table(:projects) }
+ let(:builds) { table(:ci_builds) }
+ let(:job_artifacts) { table(:ci_job_artifacts) }
+
+ before do
+ namespaces.create!(id: 123, name: 'sample', path: 'sample')
+ projects.create!(id: 123, name: 'sample', path: 'sample', namespace_id: 123)
+ builds.create!(id: 1)
+ end
+
+ context 'when file_store is nil' do
+ it 'updates file_store to local' do
+ job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: nil)
+ job_artifact = job_artifacts.find_by(project_id: 123, job_id: 1)
+
+ expect { migrate! }.to change { job_artifact.reload.file_store }.from(nil).to(1)
+ end
+ end
+
+ context 'when file_store is set to local' do
+ it 'does not update file_store' do
+ job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: 1)
+ job_artifact = job_artifacts.find_by(project_id: 123, job_id: 1)
+
+ expect { migrate! }.not_to change { job_artifact.reload.file_store }
+ end
+ end
+
+ context 'when file_store is set to object storage' do
+ it 'does not update file_store' do
+ job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: 2)
+ job_artifact = job_artifacts.find_by(project_id: 123, job_id: 1)
+
+ expect { migrate! }.not_to change { job_artifact.reload.file_store }
+ end
+ end
+end