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/requests/api/lint_spec.rb')
-rw-r--r--spec/requests/api/lint_spec.rb41
1 files changed, 28 insertions, 13 deletions
diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb
index ef7f5ee87dc..5d8ed3dd0f5 100644
--- a/spec/requests/api/lint_spec.rb
+++ b/spec/requests/api/lint_spec.rb
@@ -123,6 +123,7 @@ RSpec.describe API::Lint do
expect(json_response['status']).to eq('valid')
expect(json_response['warnings']).to match_array([])
expect(json_response['errors']).to match_array([])
+ expect(json_response['includes']).to eq([])
end
it 'outputs expanded yaml content' do
@@ -153,19 +154,6 @@ RSpec.describe API::Lint do
end
end
- context 'with valid .gitlab-ci.yml using deprecated keywords' do
- let(:yaml_content) { { job: { script: 'ls', type: 'test' }, types: ['test'] }.to_yaml }
-
- it 'passes validation but returns warnings' do
- post api('/ci/lint', api_user), params: { content: yaml_content }
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['status']).to eq('valid')
- expect(json_response['warnings']).not_to be_empty
- expect(json_response['errors']).to match_array([])
- end
- end
-
context 'with an invalid .gitlab-ci.yml' do
context 'with invalid syntax' do
let(:yaml_content) { 'invalid content' }
@@ -177,6 +165,7 @@ RSpec.describe API::Lint do
expect(json_response['status']).to eq('invalid')
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['Invalid configuration format'])
+ expect(json_response['includes']).to eq(nil)
end
it 'outputs expanded yaml content' do
@@ -204,6 +193,7 @@ RSpec.describe API::Lint do
expect(json_response['status']).to eq('invalid')
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
+ expect(json_response['includes']).to eq([])
end
it 'outputs expanded yaml content' do
@@ -262,6 +252,17 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash
expect(json_response['merged_yaml']).to eq(expected_yaml)
+ expect(json_response['includes']).to contain_exactly(
+ {
+ 'type' => 'local',
+ 'location' => 'another-gitlab-ci.yml',
+ 'blob' => "http://localhost/#{project.full_path}/-/blob/#{project.commit.sha}/another-gitlab-ci.yml",
+ 'raw' => "http://localhost/#{project.full_path}/-/raw/#{project.commit.sha}/another-gitlab-ci.yml",
+ 'extra' => {},
+ 'context_project' => project.full_path,
+ 'context_sha' => project.commit.sha
+ }
+ )
expect(json_response['valid']).to eq(true)
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq([])
@@ -274,6 +275,7 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['merged_yaml']).to eq(yaml_content)
+ expect(json_response['includes']).to eq([])
expect(json_response['valid']).to eq(false)
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
@@ -327,6 +329,7 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['merged_yaml']).to eq(nil)
+ expect(json_response['includes']).to eq(nil)
expect(json_response['valid']).to eq(false)
expect(json_response['warnings']).to eq([])
expect(json_response['errors']).to eq(['Insufficient permissions to create a new pipeline'])
@@ -539,6 +542,17 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash
expect(json_response['merged_yaml']).to eq(expected_yaml)
+ expect(json_response['includes']).to contain_exactly(
+ {
+ 'type' => 'local',
+ 'location' => 'another-gitlab-ci.yml',
+ 'blob' => "http://localhost/#{project.full_path}/-/blob/#{project.commit.sha}/another-gitlab-ci.yml",
+ 'raw' => "http://localhost/#{project.full_path}/-/raw/#{project.commit.sha}/another-gitlab-ci.yml",
+ 'extra' => {},
+ 'context_project' => project.full_path,
+ 'context_sha' => project.commit.sha
+ }
+ )
expect(json_response['valid']).to eq(true)
expect(json_response['errors']).to eq([])
end
@@ -550,6 +564,7 @@ RSpec.describe API::Lint do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['merged_yaml']).to eq(yaml_content)
+ expect(json_response['includes']).to eq([])
expect(json_response['valid']).to eq(false)
expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
end