diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-10 17:22:58 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-25 15:13:48 +0300 |
commit | 045d07bab37df2020f650f7354157f5267f57c8a (patch) | |
tree | e99aad48ed248daa02ff1d7fe9250b327ffa77bb /spec/workers/cleanup_container_repository_worker_spec.rb | |
parent | 267ce96e36ecec169b02410bfea85e6d31715910 (diff) |
Add Container Registry API
This includes a set of APIs to manipulate container registry.
This includes also an ability to delete tags based on requested
criteria, like keep-last-n, matching-name, older-than.
Diffstat (limited to 'spec/workers/cleanup_container_repository_worker_spec.rb')
-rw-r--r-- | spec/workers/cleanup_container_repository_worker_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/workers/cleanup_container_repository_worker_spec.rb b/spec/workers/cleanup_container_repository_worker_spec.rb new file mode 100644 index 00000000000..5bee7294010 --- /dev/null +++ b/spec/workers/cleanup_container_repository_worker_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do + let(:repository) { create(:container_repository) } + let(:project) { repository.project } + let(:user) { project.owner } + let(:params) { { key: 'value' } } + + subject { described_class.new } + + describe '#perform' do + let(:service) { instance_double(Projects::ContainerRepository::CleanupTagsService) } + + before do + allow(Projects::ContainerRepository::CleanupTagsService).to receive(:new) + .with(project, user, params).and_return(service) + end + + it 'executes the destroy service' do + expect(service).to receive(:execute) + + subject.perform(user.id, repository.id, params) + end + + it 'does not raise error when user could not be found' do + expect do + subject.perform(-1, repository.id, params) + end.not_to raise_error + end + + it 'does not raise error when repository could not be found' do + expect do + subject.perform(user.id, -1, params) + end.not_to raise_error + end + + context 'when executed twice in short period' do + it 'executes service only for the first time' do + expect(service).to receive(:execute).once + + 2.times { subject.perform(user.id, repository.id, params) } + end + end + end +end |