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/services/projects/container_repository/gitlab/cleanup_tags_service_spec.rb')
-rw-r--r--spec/services/projects/container_repository/gitlab/cleanup_tags_service_spec.rb54
1 files changed, 35 insertions, 19 deletions
diff --git a/spec/services/projects/container_repository/gitlab/cleanup_tags_service_spec.rb b/spec/services/projects/container_repository/gitlab/cleanup_tags_service_spec.rb
index b06a5709bd5..f662d8bfc0c 100644
--- a/spec/services/projects/container_repository/gitlab/cleanup_tags_service_spec.rb
+++ b/spec/services/projects/container_repository/gitlab/cleanup_tags_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Projects::ContainerRepository::Gitlab::CleanupTagsService do
+RSpec.describe Projects::ContainerRepository::Gitlab::CleanupTagsService, feature_category: :container_registry do
using RSpec::Parameterized::TableSyntax
include_context 'for a cleanup tags service'
@@ -11,11 +11,13 @@ RSpec.describe Projects::ContainerRepository::Gitlab::CleanupTagsService do
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, :private) }
- let(:repository) { create(:container_repository, :root, :import_done, project: project) }
+ let(:repository) { create(:container_repository, :root, project: project) }
let(:service) { described_class.new(container_repository: repository, current_user: user, params: params) }
let(:tags) { %w[latest A Ba Bb C D E] }
before do
+ allow(repository).to receive(:migrated?).and_return(true)
+
project.add_maintainer(user) if user
stub_container_registry_config(enabled: true)
@@ -47,23 +49,23 @@ RSpec.describe Projects::ContainerRepository::Gitlab::CleanupTagsService do
let(:tags_page_size) { 2 }
it_behaves_like 'when regex matching everything is specified',
- delete_expectations: [%w[A], %w[Ba Bb], %w[C D], %w[E]]
+ delete_expectations: [%w[A], %w[Ba Bb], %w[C D], %w[E]]
it_behaves_like 'when regex matching everything is specified and latest is not kept',
- delete_expectations: [%w[latest A], %w[Ba Bb], %w[C D], %w[E]]
+ delete_expectations: [%w[latest A], %w[Ba Bb], %w[C D], %w[E]]
it_behaves_like 'when delete regex matching specific tags is used'
it_behaves_like 'when delete regex matching specific tags is used with overriding allow regex'
it_behaves_like 'with allow regex value',
- delete_expectations: [%w[A], %w[C D], %w[E]]
+ delete_expectations: [%w[A], %w[C D], %w[E]]
it_behaves_like 'when keeping only N tags',
- delete_expectations: [%w[Bb]]
+ delete_expectations: [%w[Bb]]
it_behaves_like 'when not keeping N tags',
- delete_expectations: [%w[A], %w[Ba Bb], %w[C]]
+ delete_expectations: [%w[A], %w[Ba Bb], %w[C]]
context 'when removing keeping only 3' do
let(:params) do
@@ -77,13 +79,13 @@ RSpec.describe Projects::ContainerRepository::Gitlab::CleanupTagsService do
end
it_behaves_like 'when removing older than 1 day',
- delete_expectations: [%w[Ba Bb], %w[C]]
+ delete_expectations: [%w[Ba Bb], %w[C]]
it_behaves_like 'when combining all parameters',
- delete_expectations: [%w[Bb], %w[C]]
+ delete_expectations: [%w[Bb], %w[C]]
it_behaves_like 'when running a container_expiration_policy',
- delete_expectations: [%w[Bb], %w[C]]
+ delete_expectations: [%w[Bb], %w[C]]
context 'with a timeout' do
let(:params) do
@@ -111,7 +113,7 @@ RSpec.describe Projects::ContainerRepository::Gitlab::CleanupTagsService do
end
it_behaves_like 'when regex matching everything is specified',
- delete_expectations: [%w[A], %w[Ba Bb], %w[C D], %w[E]]
+ delete_expectations: [%w[A], %w[Ba Bb], %w[C D], %w[E]]
end
end
end
@@ -120,32 +122,46 @@ RSpec.describe Projects::ContainerRepository::Gitlab::CleanupTagsService do
let(:tags_page_size) { 1000 }
it_behaves_like 'when regex matching everything is specified',
- delete_expectations: [%w[A Ba Bb C D E]]
+ delete_expectations: [%w[A Ba Bb C D E]]
it_behaves_like 'when delete regex matching specific tags is used'
it_behaves_like 'when delete regex matching specific tags is used with overriding allow regex'
it_behaves_like 'with allow regex value',
- delete_expectations: [%w[A C D E]]
+ delete_expectations: [%w[A C D E]]
it_behaves_like 'when keeping only N tags',
- delete_expectations: [%w[Ba Bb C]]
+ delete_expectations: [%w[Ba Bb C]]
it_behaves_like 'when not keeping N tags',
- delete_expectations: [%w[A Ba Bb C]]
+ delete_expectations: [%w[A Ba Bb C]]
it_behaves_like 'when removing keeping only 3',
- delete_expectations: [%w[Ba Bb C]]
+ delete_expectations: [%w[Ba Bb C]]
it_behaves_like 'when removing older than 1 day',
- delete_expectations: [%w[Ba Bb C]]
+ delete_expectations: [%w[Ba Bb C]]
it_behaves_like 'when combining all parameters',
- delete_expectations: [%w[Ba Bb C]]
+ delete_expectations: [%w[Ba Bb C]]
it_behaves_like 'when running a container_expiration_policy',
- delete_expectations: [%w[Ba Bb C]]
+ delete_expectations: [%w[Ba Bb C]]
+ end
+
+ context 'with no tags page' do
+ let(:tags_page_size) { 1000 }
+ let(:deleted) { [] }
+ let(:params) { {} }
+
+ before do
+ allow(repository.gitlab_api_client)
+ .to receive(:tags)
+ .and_return({})
+ end
+
+ it { is_expected.to eq(expected_service_response(status: :success, deleted: [], original_size: 0)) }
end
end