diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/migrations/20220329175119_remove_leftover_ci_job_artifact_deletions_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/migrations/20220329175119_remove_leftover_ci_job_artifact_deletions_spec.rb')
-rw-r--r-- | spec/migrations/20220329175119_remove_leftover_ci_job_artifact_deletions_spec.rb | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/spec/migrations/20220329175119_remove_leftover_ci_job_artifact_deletions_spec.rb b/spec/migrations/20220329175119_remove_leftover_ci_job_artifact_deletions_spec.rb new file mode 100644 index 00000000000..13884007af2 --- /dev/null +++ b/spec/migrations/20220329175119_remove_leftover_ci_job_artifact_deletions_spec.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require 'spec_helper' + +require_migration! + +RSpec.describe RemoveLeftoverCiJobArtifactDeletions do + let(:deleted_records) { table(:loose_foreign_keys_deleted_records) } + + target_table_name = Ci::JobArtifact.table_name + + let(:pending_record1) do + deleted_records.create!( + id: 1, + fully_qualified_table_name: "public.#{target_table_name}", + primary_key_value: 1, + status: 1 + ) + end + + let(:pending_record2) do + deleted_records.create!( + id: 2, + fully_qualified_table_name: "public.#{target_table_name}", + primary_key_value: 2, + status: 1 + ) + end + + let(:other_pending_record1) do + deleted_records.create!( + id: 3, + fully_qualified_table_name: 'public.projects', + primary_key_value: 1, + status: 1 + ) + end + + let(:other_pending_record2) do + deleted_records.create!( + id: 4, + fully_qualified_table_name: 'public.ci_builds', + primary_key_value: 1, + status: 1 + ) + end + + let(:processed_record1) do + deleted_records.create!( + id: 5, + fully_qualified_table_name: 'public.external_pull_requests', + primary_key_value: 3, + status: 2 + ) + end + + let(:other_processed_record1) do + deleted_records.create!( + id: 6, + fully_qualified_table_name: 'public.ci_builds', + primary_key_value: 2, + status: 2 + ) + end + + let!(:persisted_ids_before) do + [ + pending_record1, + pending_record2, + other_pending_record1, + other_pending_record2, + processed_record1, + other_processed_record1 + ].map(&:id).sort + end + + let!(:persisted_ids_after) do + [ + other_pending_record1, + other_pending_record2, + processed_record1, + other_processed_record1 + ].map(&:id).sort + end + + def all_ids + deleted_records.all.map(&:id).sort + end + + it 'deletes pending external_pull_requests records' do + expect { migrate! }.to change { all_ids }.from(persisted_ids_before).to(persisted_ids_after) + end +end |