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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-16 18:09:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-16 18:09:59 +0300
commit0c87da93750c6428328a3e3cd2ebd0882f6294e3 (patch)
tree1b6cb32a86a461e592634249db84f34b44d0c2eb /spec/services
parentd87800c3cfa21bde64704542d61a587c5ff4306e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/google_cloud/generate_pipeline_service_spec.rb94
-rw-r--r--spec/services/search_service_spec.rb22
2 files changed, 116 insertions, 0 deletions
diff --git a/spec/services/google_cloud/generate_pipeline_service_spec.rb b/spec/services/google_cloud/generate_pipeline_service_spec.rb
index c18514884ca..b363b7b17b6 100644
--- a/spec/services/google_cloud/generate_pipeline_service_spec.rb
+++ b/spec/services/google_cloud/generate_pipeline_service_spec.rb
@@ -236,4 +236,98 @@ EOF
end
end
end
+
+ describe 'for vision ai' do
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:maintainer) { create(:user) }
+ let_it_be(:service_params) { { action: described_class::ACTION_VISION_AI_PIPELINE } }
+ let_it_be(:service) { described_class.new(project, maintainer, service_params) }
+
+ describe 'when there is no existing pipeline' do
+ before do
+ project.add_maintainer(maintainer)
+ end
+
+ it 'creates a new branch with commit for cloud-run deployment' do
+ response = service.execute
+
+ branch_name = response[:branch_name]
+ commit = response[:commit]
+ local_branches = project.repository.local_branches
+ created_branch = local_branches.find { |branch| branch.name == branch_name }
+
+ expect(response[:status]).to eq(:success)
+ expect(branch_name).to start_with('vision-ai-pipeline-')
+ expect(created_branch).to be_present
+ expect(created_branch.target).to eq(commit[:result])
+ end
+
+ it 'generated pipeline includes vision ai deployment' do
+ response = service.execute
+
+ ref = response[:commit][:result]
+ gitlab_ci_yml = project.repository.gitlab_ci_yml_for(ref)
+
+ expect(response[:status]).to eq(:success)
+ expect(gitlab_ci_yml).to include('https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/library/-/raw/main/gcp/vision-ai.gitlab-ci.yml')
+ end
+
+ context 'simulate errors' do
+ it 'fails to create branch' do
+ allow_next_instance_of(Branches::CreateService) do |create_service|
+ allow(create_service).to receive(:execute)
+ .and_return({ status: :error })
+ end
+
+ response = service.execute
+ expect(response[:status]).to eq(:error)
+ end
+
+ it 'fails to commit changes' do
+ allow_next_instance_of(Files::CreateService) do |create_service|
+ allow(create_service).to receive(:execute)
+ .and_return({ status: :error })
+ end
+
+ response = service.execute
+ expect(response[:status]).to eq(:error)
+ end
+ end
+ end
+
+ describe 'when there is an existing pipeline with `includes`' do
+ before do
+ project.add_maintainer(maintainer)
+
+ file_name = '.gitlab-ci.yml'
+ file_content = <<EOF
+stages:
+ - validate
+ - detect
+ - render
+
+include:
+ local: 'some-pipeline.yml'
+EOF
+ project.repository.create_file(maintainer,
+ file_name,
+ file_content,
+ message: 'Pipeline with three stages and two jobs',
+ branch_name: project.default_branch)
+ end
+
+ it 'includes the vision ai pipeline' do
+ response = service.execute
+
+ branch_name = response[:branch_name]
+ gitlab_ci_yml = project.repository.gitlab_ci_yml_for(branch_name)
+ pipeline = Gitlab::Config::Loader::Yaml.new(gitlab_ci_yml).load!
+
+ expect(response[:status]).to eq(:success)
+ expect(pipeline[:stages]).to eq(%w[validate detect render])
+ expect(pipeline[:include]).to be_present
+ expect(gitlab_ci_yml).to include('https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/library/-/raw/main/gcp/vision-ai.gitlab-ci.yml')
+ end
+ end
+ end
end
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb
index d11fc377d83..c937a93c6ef 100644
--- a/spec/services/search_service_spec.rb
+++ b/spec/services/search_service_spec.rb
@@ -485,6 +485,8 @@ RSpec.describe SearchService, feature_category: :global_search do
'issues' | :global_search_issues_tab | true | true
'merge_requests' | :global_search_merge_requests_tab | false | false
'merge_requests' | :global_search_merge_requests_tab | true | true
+ 'snippet_titles' | :global_search_snippet_titles_tab | false | false
+ 'snippet_titles' | :global_search_snippet_titles_tab | true | true
'wiki_blobs' | :global_search_wiki_tab | false | false
'wiki_blobs' | :global_search_wiki_tab | true | true
'users' | :global_search_users_tab | false | false
@@ -498,5 +500,25 @@ RSpec.describe SearchService, feature_category: :global_search do
expect(subject.global_search_enabled_for_scope?).to eq expected
end
end
+
+ context 'when snippet search is enabled' do
+ let(:scope) { 'snippet_titles' }
+
+ before do
+ allow(described_class).to receive(:show_snippets?).and_return(true)
+ end
+
+ it 'returns false when feature_flag is not enabled' do
+ stub_feature_flags(global_search_snippet_titles_tab: false)
+
+ expect(subject.global_search_enabled_for_scope?).to eq false
+ end
+
+ it 'returns true when feature_flag is enabled' do
+ stub_feature_flags(global_search_snippet_titles_tab: true)
+
+ expect(subject.global_search_enabled_for_scope?).to eq true
+ end
+ end
end
end