diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-29 00:07:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-29 00:07:58 +0300 |
commit | fcfe959a5ddee652a27e6b1179a116fdbb70986b (patch) | |
tree | 4dbcf2a93aaaf4952507207168c582f5948efaa3 /spec/lib | |
parent | 7f3f19582b13b4162212bcf0ae72eef63685ffbc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/ci/config/external/mapper_spec.rb | 24 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/parsers/security/common_spec.rb | 20 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/codequality_reports_comparer_spec.rb | 33 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/codequality_reports_spec.rb | 32 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/variables/builder/group_spec.rb | 11 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/variables/builder/project_spec.rb | 11 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/variables/builder_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/variables/collection/sort_spec.rb | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor/result_spec.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 140 | ||||
-rw-r--r-- | spec/lib/gitlab/conflict/file_spec.rb | 27 |
11 files changed, 175 insertions, 156 deletions
diff --git a/spec/lib/gitlab/ci/config/external/mapper_spec.rb b/spec/lib/gitlab/ci/config/external/mapper_spec.rb index c13e65084c1..e12f5dcee0a 100644 --- a/spec/lib/gitlab/ci/config/external/mapper_spec.rb +++ b/spec/lib/gitlab/ci/config/external/mapper_spec.rb @@ -207,9 +207,9 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do context "when duplicate 'include's are defined" do let(:values) do { include: [ - { 'local' => local_file }, - { 'local' => local_file } - ], + { 'local' => local_file }, + { 'local' => local_file } + ], image: 'image:1.0' } end @@ -226,9 +226,9 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do context 'when passing max number of files' do let(:values) do { include: [ - { 'local' => local_file }, - { 'remote' => remote_url } - ], + { 'local' => local_file }, + { 'remote' => remote_url } + ], image: 'image:1.0' } end @@ -242,9 +242,9 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do context "when too many 'includes' are defined" do let(:values) do { include: [ - { 'local' => local_file }, - { 'remote' => remote_url } - ], + { 'local' => local_file }, + { 'remote' => remote_url } + ], image: 'image:1.0' } end @@ -425,9 +425,9 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do let(:values) do { include: [ - { 'local' => 'hello/secret-file1.yml' }, - { 'local' => 'hello/secret-file2.yml' } - ], + { 'local' => 'hello/secret-file1.yml' }, + { 'local' => 'hello/secret-file2.yml' } + ], image: 'ruby:2.7' } end diff --git a/spec/lib/gitlab/ci/parsers/security/common_spec.rb b/spec/lib/gitlab/ci/parsers/security/common_spec.rb index 828c980dc9a..7dbad354e4c 100644 --- a/spec/lib/gitlab/ci/parsers/security/common_spec.rb +++ b/spec/lib/gitlab/ci/parsers/security/common_spec.rb @@ -404,11 +404,11 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Common do { 'type' => 'source', 'items' => [ - 'signatures' => [ - { 'algorithm' => 'hash', 'value' => 'hash_value' }, - { 'algorithm' => 'location', 'value' => 'location_value' }, - { 'algorithm' => 'scope_offset', 'value' => 'scope_offset_value' } - ] + 'signatures' => [ + { 'algorithm' => 'hash', 'value' => 'hash_value' }, + { 'algorithm' => 'location', 'value' => 'location_value' }, + { 'algorithm' => 'scope_offset', 'value' => 'scope_offset_value' } + ] ] } end @@ -426,11 +426,11 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Common do { 'type' => 'source', 'items' => [ - 'signatures' => [ - { 'algorithm' => 'hash', 'value' => 'hash_value' }, - { 'algorithm' => 'location', 'value' => 'location_value' }, - { 'algorithm' => 'INVALID', 'value' => 'scope_offset_value' } - ] + 'signatures' => [ + { 'algorithm' => 'hash', 'value' => 'hash_value' }, + { 'algorithm' => 'location', 'value' => 'location_value' }, + { 'algorithm' => 'INVALID', 'value' => 'scope_offset_value' } + ] ] } end diff --git a/spec/lib/gitlab/ci/reports/codequality_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/codequality_reports_comparer_spec.rb index e289e59b281..effa2c43418 100644 --- a/spec/lib/gitlab/ci/reports/codequality_reports_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/codequality_reports_comparer_spec.rb @@ -191,11 +191,12 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do end it 'includes the base report errors sorted by severity' do - expect(existing_errors).to eq([ - blocker_degradation, - critical_degradation, - major_degradation - ]) + expect(existing_errors).to eq( + [ + blocker_degradation, + critical_degradation, + major_degradation + ]) end end @@ -242,11 +243,12 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do end it 'includes errors not found in the base report sorted by severity' do - expect(new_errors).to eq([ - blocker_degradation, - critical_degradation, - minor_degradation - ]) + expect(new_errors).to eq( + [ + blocker_degradation, + critical_degradation, + minor_degradation + ]) end end @@ -304,11 +306,12 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReportsComparer do end it 'returns the base report errors not found in the head report, sorted by severity' do - expect(resolved_errors).to eq([ - blocker_degradation, - critical_degradation, - minor_degradation - ]) + expect(resolved_errors).to eq( + [ + blocker_degradation, + critical_degradation, + minor_degradation + ]) end end diff --git a/spec/lib/gitlab/ci/reports/codequality_reports_spec.rb b/spec/lib/gitlab/ci/reports/codequality_reports_spec.rb index f4b47893805..68e70525c55 100644 --- a/spec/lib/gitlab/ci/reports/codequality_reports_spec.rb +++ b/spec/lib/gitlab/ci/reports/codequality_reports_spec.rb @@ -103,15 +103,16 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReports do end it 'sorts degradations based on severity' do - expect(codequality_report.degradations.values).to eq([ - blocker, - critical, - major, - major_2, - minor, - info, - unknown - ]) + expect(codequality_report.degradations.values).to eq( + [ + blocker, + critical, + major, + major_2, + minor, + info, + unknown + ]) end context 'with non-existence and uppercase severities' do @@ -126,12 +127,13 @@ RSpec.describe Gitlab::Ci::Reports::CodequalityReports do end it 'sorts unknown last' do - expect(other_report.degradations.values).to eq([ - blocker, - uppercase_major, - minor, - non_existent - ]) + expect(other_report.degradations.values).to eq( + [ + blocker, + uppercase_major, + minor, + non_existent + ]) end end end diff --git a/spec/lib/gitlab/ci/variables/builder/group_spec.rb b/spec/lib/gitlab/ci/variables/builder/group_spec.rb index 72487588cde..c3743ebd2d7 100644 --- a/spec/lib/gitlab/ci/variables/builder/group_spec.rb +++ b/spec/lib/gitlab/ci/variables/builder/group_spec.rb @@ -132,11 +132,12 @@ RSpec.describe Gitlab::Ci::Variables::Builder::Group do end it 'orders the variables from least to most matched' do - variables_collection = Gitlab::Ci::Variables::Collection.new([ - variable, - partially_matched_variable, - perfectly_matched_variable - ]).to_runner_variables + variables_collection = Gitlab::Ci::Variables::Collection.new( + [ + variable, + partially_matched_variable, + perfectly_matched_variable + ]).to_runner_variables expect(subject.to_runner_variables).to eq(variables_collection) end diff --git a/spec/lib/gitlab/ci/variables/builder/project_spec.rb b/spec/lib/gitlab/ci/variables/builder/project_spec.rb index b64b6ea98e2..c1cefc425f5 100644 --- a/spec/lib/gitlab/ci/variables/builder/project_spec.rb +++ b/spec/lib/gitlab/ci/variables/builder/project_spec.rb @@ -132,11 +132,12 @@ RSpec.describe Gitlab::Ci::Variables::Builder::Project do end it 'puts variables matching environment scope more in the end' do - variables_collection = Gitlab::Ci::Variables::Collection.new([ - variable, - partially_matched_variable, - perfectly_matched_variable - ]).to_runner_variables + variables_collection = Gitlab::Ci::Variables::Collection.new( + [ + variable, + partially_matched_variable, + perfectly_matched_variable + ]).to_runner_variables expect(subject.to_runner_variables).to eq(variables_collection) end diff --git a/spec/lib/gitlab/ci/variables/builder_spec.rb b/spec/lib/gitlab/ci/variables/builder_spec.rb index 00a41229844..7c361e3f03f 100644 --- a/spec/lib/gitlab/ci/variables/builder_spec.rb +++ b/spec/lib/gitlab/ci/variables/builder_spec.rb @@ -264,10 +264,11 @@ RSpec.describe Gitlab::Ci::Variables::Builder, :clean_gitlab_redis_cache do end it 'includes #deployment_variables and merges the KUBECONFIG values', :aggregate_failures do - expect(builder).to receive(:deployment_variables).and_return([ - { key: 'KUBECONFIG', value: 'deployment-kubeconfig' }, - { key: 'OTHER', value: 'some value' } - ]) + expect(builder).to receive(:deployment_variables).and_return( + [ + { key: 'KUBECONFIG', value: 'deployment-kubeconfig' }, + { key: 'OTHER', value: 'some value' } + ]) expect(template).to receive(:merge_yaml).with('deployment-kubeconfig') expect(subject['KUBECONFIG'].value).to eq('example-kubeconfig') expect(subject['OTHER'].value).to eq('some value') diff --git a/spec/lib/gitlab/ci/variables/collection/sort_spec.rb b/spec/lib/gitlab/ci/variables/collection/sort_spec.rb index 57171e5be69..432225c53f0 100644 --- a/spec/lib/gitlab/ci/variables/collection/sort_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection/sort_spec.rb @@ -192,13 +192,14 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sort do end it 'preserves relative order of overridden variables' do - is_expected.to eq([ - { 'TOP_LEVEL_GROUP_NAME' => 'top-level-group' }, - { 'SUBGROUP_VAR' => '$TOP_LEVEL_GROUP_NAME' }, - { 'SUB_GROUP_NAME' => 'vars-in-vars-subgroup' }, - { 'SUBGROUP_VAR' => '$SUB_GROUP_NAME' }, - { 'PROJECT_VAR' => '$SUBGROUP_VAR' } - ]) + is_expected.to eq( + [ + { 'TOP_LEVEL_GROUP_NAME' => 'top-level-group' }, + { 'SUBGROUP_VAR' => '$TOP_LEVEL_GROUP_NAME' }, + { 'SUB_GROUP_NAME' => 'vars-in-vars-subgroup' }, + { 'SUBGROUP_VAR' => '$SUB_GROUP_NAME' }, + { 'PROJECT_VAR' => '$SUBGROUP_VAR' } + ]) end end end diff --git a/spec/lib/gitlab/ci/yaml_processor/result_spec.rb b/spec/lib/gitlab/ci/yaml_processor/result_spec.rb index f7a0905d9da..7f203168706 100644 --- a/spec/lib/gitlab/ci/yaml_processor/result_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor/result_spec.rb @@ -71,10 +71,11 @@ module Gitlab subject(:yaml_variables_for) { result.yaml_variables_for(job_name) } it 'returns calculated variables with root and job variables' do - is_expected.to match_array([ - { key: 'VAR1', value: 'value 11' }, - { key: 'VAR2', value: 'value 2' } - ]) + is_expected.to match_array( + [ + { key: 'VAR1', value: 'value 11' }, + { key: 'VAR2', value: 'value 2' } + ]) end context 'when an absent job is sent' do diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index b710ee092ec..cbc83bcaee3 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1524,13 +1524,14 @@ module Gitlab config_processor = Gitlab::Ci::YamlProcessor.new(config).execute expect(config_processor.stage_builds_attributes("test").size).to eq(1) - expect(config_processor.stage_builds_attributes("test").first[:cache]).to eq([ - paths: ["logs/", "binaries/"], - untracked: true, - key: 'key', - policy: 'pull-push', - when: 'on_success' - ]) + expect(config_processor.stage_builds_attributes("test").first[:cache]).to eq( + [ + paths: ["logs/", "binaries/"], + untracked: true, + key: 'key', + policy: 'pull-push', + when: 'on_success' + ]) end it "returns cache when defined in default context" do @@ -1547,25 +1548,27 @@ module Gitlab config_processor = Gitlab::Ci::YamlProcessor.new(config).execute expect(config_processor.stage_builds_attributes("test").size).to eq(1) - expect(config_processor.stage_builds_attributes("test").first[:cache]).to eq([ - paths: ["logs/", "binaries/"], - untracked: true, - key: { files: ['file'] }, - policy: 'pull-push', - when: 'on_success' - ]) + expect(config_processor.stage_builds_attributes("test").first[:cache]).to eq( + [ + paths: ["logs/", "binaries/"], + untracked: true, + key: { files: ['file'] }, + policy: 'pull-push', + when: 'on_success' + ]) end it 'returns cache key/s when defined in a job' do - config = YAML.dump({ - rspec: { - cache: [ - { paths: ['binaries/'], untracked: true, key: 'keya' }, - { paths: ['logs/', 'binaries/'], untracked: true, key: 'key' } - ], - script: 'rspec' - } - }) + config = YAML.dump( + { + rspec: { + cache: [ + { paths: ['binaries/'], untracked: true, key: 'keya' }, + { paths: ['logs/', 'binaries/'], untracked: true, key: 'key' } + ], + script: 'rspec' + } + }) config_processor = Gitlab::Ci::YamlProcessor.new(config).execute @@ -1605,13 +1608,14 @@ module Gitlab config_processor = Gitlab::Ci::YamlProcessor.new(config).execute expect(config_processor.stage_builds_attributes('test').size).to eq(1) - expect(config_processor.stage_builds_attributes('test').first[:cache]).to eq([ - paths: ['binaries/'], - untracked: true, - key: { files: ['file'] }, - policy: 'pull-push', - when: 'on_success' - ]) + expect(config_processor.stage_builds_attributes('test').first[:cache]).to eq( + [ + paths: ['binaries/'], + untracked: true, + key: { files: ['file'] }, + policy: 'pull-push', + when: 'on_success' + ]) end it 'returns cache files with prefix' do @@ -1629,54 +1633,58 @@ module Gitlab config_processor = Gitlab::Ci::YamlProcessor.new(config).execute expect(config_processor.stage_builds_attributes('test').size).to eq(1) - expect(config_processor.stage_builds_attributes('test').first[:cache]).to eq([ - paths: ['logs/', 'binaries/'], - untracked: true, - key: { files: ['file'], prefix: 'prefix' }, - policy: 'pull-push', - when: 'on_success' - ]) + expect(config_processor.stage_builds_attributes('test').first[:cache]).to eq( + [ + paths: ['logs/', 'binaries/'], + untracked: true, + key: { files: ['file'], prefix: 'prefix' }, + policy: 'pull-push', + when: 'on_success' + ]) end it "overwrite cache when defined for a job and globally" do - config = YAML.dump({ - cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'global' }, - rspec: { - script: "rspec", - cache: { paths: ["test/"], untracked: false, key: 'local' } - } - }) + config = YAML.dump( + { + cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'global' }, + rspec: { + script: "rspec", + cache: { paths: ["test/"], untracked: false, key: 'local' } + } + }) config_processor = Gitlab::Ci::YamlProcessor.new(config).execute expect(config_processor.stage_builds_attributes("test").size).to eq(1) - expect(config_processor.stage_builds_attributes("test").first[:cache]).to eq([ - paths: ["test/"], - untracked: false, - key: 'local', - policy: 'pull-push', - when: 'on_success' - ]) + expect(config_processor.stage_builds_attributes("test").first[:cache]).to eq( + [ + paths: ["test/"], + untracked: false, + key: 'local', + policy: 'pull-push', + when: 'on_success' + ]) end end describe "Artifacts" do it "returns artifacts when defined" do - config = YAML.dump({ - image: "image:1.0", - services: ["mysql"], - before_script: ["pwd"], - rspec: { - artifacts: { - paths: ["logs/", "binaries/"], - expose_as: "Exposed artifacts", - untracked: true, - name: "custom_name", - expire_in: "7d" - }, - script: "rspec" - } - }) + config = YAML.dump( + { + image: "image:1.0", + services: ["mysql"], + before_script: ["pwd"], + rspec: { + artifacts: { + paths: ["logs/", "binaries/"], + expose_as: "Exposed artifacts", + untracked: true, + name: "custom_name", + expire_in: "7d" + }, + script: "rspec" + } + }) config_processor = Gitlab::Ci::YamlProcessor.new(config).execute diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index aac4936b20e..1fa6eee9813 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -141,19 +141,20 @@ RSpec.describe Gitlab::Conflict::File do let(:raw_conflict_content) { index.merge_file('files/ruby/popen.rb')[:data] } it 'assign conflict types and adds match line to the end of the section' do - expect(diff_line_types).to eq([ - 'match', - nil, nil, nil, - "conflict_marker_our", - "conflict_our", - "conflict_marker", - "conflict_their", - "conflict_their", - "conflict_their", - "conflict_marker_their", - nil, nil, nil, - "match" - ]) + expect(diff_line_types).to eq( + [ + 'match', + nil, nil, nil, + "conflict_marker_our", + "conflict_our", + "conflict_marker", + "conflict_their", + "conflict_their", + "conflict_their", + "conflict_marker_their", + nil, nil, nil, + "match" + ]) end end end |