diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-04 15:13:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-04 15:13:46 +0300 |
commit | 76893705a1df96909da44ab3c99816fd12129206 (patch) | |
tree | e9ec48a022223fbdf7588a6e2bbafd5dff22903a /spec/requests | |
parent | cb19d2b6a3b6becdede8d9398fbd17dedb99a8bf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql/ci/config_spec.rb | 18 | ||||
-rw-r--r-- | spec/requests/api/lint_spec.rb | 19 |
2 files changed, 34 insertions, 3 deletions
diff --git a/spec/requests/api/graphql/ci/config_spec.rb b/spec/requests/api/graphql/ci/config_spec.rb index 8ede6e1538c..b7a8b23ac85 100644 --- a/spec/requests/api/graphql/ci/config_spec.rb +++ b/spec/requests/api/graphql/ci/config_spec.rb @@ -20,6 +20,7 @@ RSpec.describe 'Query.ciConfig' do ciConfig(projectPath: "#{project.full_path}", content: "#{content}", dryRun: false) { status errors + warnings stages { nodes { name @@ -73,6 +74,7 @@ RSpec.describe 'Query.ciConfig' do expect(graphql_data['ciConfig']).to eq( "status" => "VALID", "errors" => [], + "warnings" => [], "stages" => { "nodes" => @@ -220,6 +222,21 @@ RSpec.describe 'Query.ciConfig' do ) end + context 'when using deprecated keywords' do + let_it_be(:content) do + YAML.dump( + rspec: { script: 'ls' }, + types: ['test'] + ) + end + + it 'returns a warning' do + post_graphql_query + + expect(graphql_data['ciConfig']['warnings']).to include('root `types` is deprecated in 9.0 and will be removed in 15.0 - read more: https://docs.gitlab.com/ee/ci/yaml/#deprecated-keywords') + end + end + context 'when the config file includes other files' do let_it_be(:content) do YAML.dump( @@ -250,6 +267,7 @@ RSpec.describe 'Query.ciConfig' do expect(graphql_data['ciConfig']).to eq( "status" => "VALID", "errors" => [], + "warnings" => [], "stages" => { "nodes" => diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb index 0e83b964121..7c1e731a99a 100644 --- a/spec/requests/api/lint_spec.rb +++ b/spec/requests/api/lint_spec.rb @@ -121,8 +121,8 @@ RSpec.describe API::Lint do expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_an Hash expect(json_response['status']).to eq('valid') - expect(json_response['warnings']).to eq([]) - expect(json_response['errors']).to eq([]) + expect(json_response['warnings']).to match_array([]) + expect(json_response['errors']).to match_array([]) end it 'outputs expanded yaml content' do @@ -149,7 +149,20 @@ RSpec.describe API::Lint do 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 eq([]) + expect(json_response['errors']).to match_array([]) + end + end + + context 'with valid .gitlab-ci.yaml using deprecated keywords' do + let(:yaml_content) { { job: { script: 'ls' }, 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 |