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/ci/catalog/resources/validate_service_spec.rb')
-rw-r--r--spec/services/ci/catalog/resources/validate_service_spec.rb77
1 files changed, 54 insertions, 23 deletions
diff --git a/spec/services/ci/catalog/resources/validate_service_spec.rb b/spec/services/ci/catalog/resources/validate_service_spec.rb
index b43d98788e2..39ab758d78d 100644
--- a/spec/services/ci/catalog/resources/validate_service_spec.rb
+++ b/spec/services/ci/catalog/resources/validate_service_spec.rb
@@ -4,54 +4,85 @@ require 'spec_helper'
RSpec.describe Ci::Catalog::Resources::ValidateService, feature_category: :pipeline_composition do
describe '#execute' do
- context 'with a project that has a README and a description' do
+ context 'when a project has a README, a description, and at least one component' do
it 'is valid' do
- project = create(:project, :repository, description: 'Component project')
+ project = create(:project, :catalog_resource_with_components)
response = described_class.new(project, project.default_branch).execute
expect(response).to be_success
end
end
- context 'with a project that has neither a description nor a README' do
+ context 'when a project has neither a description nor a README nor components' do
it 'is not valid' do
- project = create(:project, :empty_repo)
- project.repository.create_file(
- project.creator,
- 'ruby.rb',
- 'I like this',
- message: 'Ruby like this',
- branch_name: 'master'
- )
+ project = create(:project, :small_repo)
response = described_class.new(project, project.default_branch).execute
- expect(response.message).to eq('Project must have a README , Project must have a description')
+ expect(response.message).to eq(
+ 'Project must have a README, ' \
+ 'Project must have a description, ' \
+ 'Project must contain components. Ensure you are using the correct directory structure')
end
end
- context 'with a project that has a description but not a README' do
+ context 'when a project has components but has neither a description nor a README' do
it 'is not valid' do
- project = create(:project, :empty_repo, description: 'project with no README')
- project.repository.create_file(
- project.creator,
- 'text.txt',
- 'I do not like this',
- message: 'only text like text',
- branch_name: 'master'
- )
+ project = create(:project, :small_repo, files: { 'templates/dast/template.yml' => 'image: alpine' })
response = described_class.new(project, project.default_branch).execute
- expect(response.message).to eq('Project must have a README')
+ expect(response.message).to eq('Project must have a README, Project must have a description')
+ end
+ end
+
+ context 'when a project has a description but has neither a README nor components' do
+ it 'is not valid' do
+ project = create(:project, :small_repo, description: 'project with no README and no components')
+ response = described_class.new(project, project.default_branch).execute
+
+ expect(response.message).to eq(
+ 'Project must have a README, ' \
+ 'Project must contain components. Ensure you are using the correct directory structure')
end
end
- context 'with a project that has a README and not a description' do
+ context 'when a project has a README but has neither a description nor components' do
it 'is not valid' do
project = create(:project, :repository)
response = described_class.new(project, project.default_branch).execute
+ expect(response.message).to eq(
+ 'Project must have a description, ' \
+ 'Project must contain components. Ensure you are using the correct directory structure')
+ end
+ end
+
+ context 'when a project has components and a description but no README' do
+ it 'is not valid' do
+ project = create(:project, :small_repo, description: 'desc', files: { 'templates/dast.yml' => 'image: alpine' })
+ response = described_class.new(project, project.default_branch).execute
+
+ expect(response.message).to eq('Project must have a README')
+ end
+ end
+
+ context 'when a project has components and a README but no description' do
+ it 'is not valid' do
+ project = create(:project, :custom_repo,
+ files: { 'templates/dast.yml' => 'image: alpine', 'README.md' => 'readme' })
+ response = described_class.new(project, project.default_branch).execute
+
expect(response.message).to eq('Project must have a description')
end
end
+
+ context 'when a project has a description and a README but no components' do
+ it 'is not valid' do
+ project = create(:project, :readme, description: 'project with no README and no components')
+ response = described_class.new(project, project.default_branch).execute
+
+ expect(response.message).to eq(
+ 'Project must contain components. Ensure you are using the correct directory structure')
+ end
+ end
end
end