diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/tooling/lib/tooling/test_map_packer_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/tooling/lib/tooling/test_map_packer_spec.rb')
-rw-r--r-- | spec/tooling/lib/tooling/test_map_packer_spec.rb | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/spec/tooling/lib/tooling/test_map_packer_spec.rb b/spec/tooling/lib/tooling/test_map_packer_spec.rb new file mode 100644 index 00000000000..233134d2524 --- /dev/null +++ b/spec/tooling/lib/tooling/test_map_packer_spec.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +require_relative '../../../../tooling/lib/tooling/test_map_packer' + +RSpec.describe Tooling::TestMapPacker do + subject { described_class.new } + + let(:map) do + { + 'file1.rb' => [ + './a/b/c/test_1.rb', + './a/b/test_2.rb', + './a/b/test_3.rb', + './a/test_4.rb', + './test_5.rb' + ], + 'file2.rb' => [ + './a/b/c/test_1.rb', + './a/test_4.rb', + './test_5.rb' + ] + } + end + + let(:compact_map) do + { + 'file1.rb' => { + '.' => { + 'a' => { + 'b' => { + 'c' => { + 'test_1.rb' => 1 + }, + 'test_2.rb' => 1, + 'test_3.rb' => 1 + }, + 'test_4.rb' => 1 + }, + 'test_5.rb' => 1 + } + }, + 'file2.rb' => { + '.' => { + 'a' => { + 'b' => { + 'c' => { + 'test_1.rb' => 1 + } + }, + 'test_4.rb' => 1 + }, + 'test_5.rb' => 1 + } + } + } + end + + describe '#pack' do + it 'compacts list of test files into a prefix tree' do + expect(subject.pack(map)).to eq(compact_map) + end + + it 'does nothing to empty hash' do + expect(subject.pack({})).to eq({}) + end + end + + describe '#unpack' do + it 'unpack prefix tree into list of test files' do + expect(subject.unpack(compact_map)).to eq(map) + end + + it 'does nothing to empty hash' do + expect(subject.unpack({})).to eq({}) + end + end +end |