summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2017-12-05 19:56:50 +0100
committerMatija Čupić <matteeyah@gmail.com>2017-12-05 19:56:50 +0100
commit2d9670b5252ea415fd1d9f61a0016fc219e2c21e (patch)
tree38906c78f34a1716a150a8f627eecf122b7c0c7b /spec/migrations
parentfc4f3164a6ba8e5ae1bb0792ea7f1ebb4753ccb4 (diff)
parent8c77ae2d9eb40d8039f3b142d462f4705a0bf53e (diff)
downloadgitlab-ce-2d9670b5252ea415fd1d9f61a0016fc219e2c21e.tar.gz
Merge remote-tracking branch 'origin/master' into list-multiple-clusters
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/migrate_old_artifacts_spec.rb39
1 files changed, 30 insertions, 9 deletions
diff --git a/spec/migrations/migrate_old_artifacts_spec.rb b/spec/migrations/migrate_old_artifacts_spec.rb
index 81366d15b34..92eb1d9ce86 100644
--- a/spec/migrations/migrate_old_artifacts_spec.rb
+++ b/spec/migrations/migrate_old_artifacts_spec.rb
@@ -16,20 +16,22 @@ describe MigrateOldArtifacts do
end
context 'with migratable data' do
- let(:project1) { create(:project, ci_id: 2) }
- let(:project2) { create(:project, ci_id: 3) }
- let(:project3) { create(:project) }
+ set(:project1) { create(:project, ci_id: 2) }
+ set(:project2) { create(:project, ci_id: 3) }
+ set(:project3) { create(:project) }
- let(:pipeline1) { create(:ci_empty_pipeline, project: project1) }
- let(:pipeline2) { create(:ci_empty_pipeline, project: project2) }
- let(:pipeline3) { create(:ci_empty_pipeline, project: project3) }
+ set(:pipeline1) { create(:ci_empty_pipeline, project: project1) }
+ set(:pipeline2) { create(:ci_empty_pipeline, project: project2) }
+ set(:pipeline3) { create(:ci_empty_pipeline, project: project3) }
let!(:build_with_legacy_artifacts) { create(:ci_build, pipeline: pipeline1) }
let!(:build_without_artifacts) { create(:ci_build, pipeline: pipeline1) }
- let!(:build2) { create(:ci_build, :artifacts, pipeline: pipeline2) }
- let!(:build3) { create(:ci_build, :artifacts, pipeline: pipeline3) }
+ let!(:build2) { create(:ci_build, pipeline: pipeline2) }
+ let!(:build3) { create(:ci_build, pipeline: pipeline3) }
before do
+ setup_builds(build2, build3)
+
store_artifacts_in_legacy_path(build_with_legacy_artifacts)
end
@@ -38,7 +40,7 @@ describe MigrateOldArtifacts do
end
it "legacy artifacts are set" do
- expect(build_with_legacy_artifacts.artifacts_file_identifier).not_to be_nil
+ expect(build_with_legacy_artifacts.legacy_artifacts_file_identifier).not_to be_nil
end
describe '#min_id' do
@@ -113,5 +115,24 @@ describe MigrateOldArtifacts do
build.project.ci_id.to_s,
build.id.to_s)
end
+
+ def new_legacy_path(build)
+ File.join(directory,
+ build.created_at.utc.strftime('%Y_%m'),
+ build.project_id.to_s,
+ build.id.to_s)
+ end
+
+ def setup_builds(*builds)
+ builds.each do |build|
+ FileUtils.mkdir_p(new_legacy_path(build))
+
+ build.update_columns(
+ artifacts_file: 'ci_build_artifacts.zip',
+ artifacts_metadata: 'ci_build_artifacts_metadata.gz')
+
+ build.reload
+ end
+ end
end
end