diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 06:14:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 06:14:17 +0300 |
commit | edd6fda56d54d7223eb67a15341603e44c3a5f7a (patch) | |
tree | 530bac6c3c884f3973512fac94c3974b8deb818e /spec/lib/gitlab/ci/templates | |
parent | d150848f7ed150d4f1887a4bff7cc4c423c55186 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci/templates')
-rw-r--r-- | spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb | 30 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb | 20 |
2 files changed, 40 insertions, 10 deletions
diff --git a/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb index d377cf0c735..789f694b4b4 100644 --- a/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/Jobs/deploy_gitlab_ci_yaml_spec.rb @@ -27,9 +27,9 @@ RSpec.describe 'Jobs/Deploy.gitlab-ci.yml' do end describe 'the created pipeline' do - let(:project) { create(:project, :repository) } - let(:user) { project.owner } + let_it_be(:project, refind: true) { create(:project, :repository) } + let(:user) { project.owner } let(:default_branch) { 'master' } let(:pipeline_ref) { default_branch } let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_ref) } @@ -43,23 +43,23 @@ RSpec.describe 'Jobs/Deploy.gitlab-ci.yml' do allow(project).to receive(:default_branch).and_return(default_branch) end - context 'with no cluster' do + context 'with no cluster or agent' do it 'does not create any kubernetes deployment jobs' do expect(build_names).to eq %w(placeholder) end end context 'with only a disabled cluster' do - let!(:cluster) { create(:cluster, :project, :provided_by_gcp, enabled: false, projects: [project]) } + before do + create(:cluster, :project, :provided_by_gcp, enabled: false, projects: [project]) + end it 'does not create any kubernetes deployment jobs' do expect(build_names).to eq %w(placeholder) end end - context 'with an active cluster' do - let!(:cluster) { create(:cluster, :project, :provided_by_gcp, projects: [project]) } - + shared_examples_for 'pipeline with deployment jobs' do context 'on master' do it 'by default' do expect(build_names).to include('production') @@ -218,5 +218,21 @@ RSpec.describe 'Jobs/Deploy.gitlab-ci.yml' do end end end + + context 'with an agent' do + before do + create(:cluster_agent, project: project) + end + + it_behaves_like 'pipeline with deployment jobs' + end + + context 'with a cluster' do + before do + create(:cluster, :project, :provided_by_gcp, projects: [project]) + end + + it_behaves_like 'pipeline with deployment jobs' + end end end diff --git a/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb index 7602309627b..64ef6ecd7f8 100644 --- a/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb +++ b/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb @@ -148,9 +148,7 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do it_behaves_like 'no Kubernetes deployment job' end - context 'when the project has an active cluster' do - let!(:cluster) { create(:cluster, :project, :provided_by_gcp, projects: [project]) } - + shared_examples 'pipeline with Kubernetes jobs' do describe 'deployment-related builds' do context 'on default branch' do it 'does not include rollout jobs besides production' do @@ -233,6 +231,22 @@ RSpec.describe 'Auto-DevOps.gitlab-ci.yml' do end end end + + context 'when a cluster is attached' do + before do + create(:cluster, :project, :provided_by_gcp, projects: [project]) + end + + it_behaves_like 'pipeline with Kubernetes jobs' + end + + context 'when project has an Agent is present' do + before do + create(:cluster_agent, project: project) + end + + it_behaves_like 'pipeline with Kubernetes jobs' + end end describe 'buildpack detection' do |