diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-16 15:09:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-16 15:09:03 +0300 |
commit | 8215fc964a189ae5c876a10f2e7d61933a725e24 (patch) | |
tree | acdd0abd951ca0f392c7617821ab347d77c1a623 /spec/workers/packages | |
parent | a57cec4bb89b61d210d4e413571b1d85d76179f6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/packages')
-rw-r--r-- | spec/workers/packages/composer/cache_cleanup_worker_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/workers/packages/composer/cache_cleanup_worker_spec.rb b/spec/workers/packages/composer/cache_cleanup_worker_spec.rb new file mode 100644 index 00000000000..e69fe55acc2 --- /dev/null +++ b/spec/workers/packages/composer/cache_cleanup_worker_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Packages::Composer::CacheCleanupWorker, type: :worker do + describe '#perform' do + let_it_be(:group) { create(:group) } + + let!(:cache_file1) { create(:composer_cache_file, delete_at: nil, group: group, file_sha256: '124') } + let!(:cache_file2) { create(:composer_cache_file, delete_at: 2.days.from_now, group: group, file_sha256: '3456') } + let!(:cache_file3) { create(:composer_cache_file, delete_at: 1.day.ago, group: group, file_sha256: '5346') } + let!(:cache_file4) { create(:composer_cache_file, delete_at: nil, group: group, file_sha256: '56889') } + + subject { described_class.new.perform } + + before do + # emulate group deletion + cache_file4.update_columns(namespace_id: nil) + end + + it 'deletes expired packages' do + expect { subject }.to change { Packages::Composer::CacheFile.count }.by(-2) + expect { cache_file1.reload }.not_to raise_error ActiveRecord::RecordNotFound + expect { cache_file2.reload }.not_to raise_error ActiveRecord::RecordNotFound + expect { cache_file3.reload }.to raise_error ActiveRecord::RecordNotFound + expect { cache_file4.reload }.to raise_error ActiveRecord::RecordNotFound + end + end +end |