Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_map_packer_spec.rb « tooling « lib « tooling « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 233134d252474bcfcd4f3108f63be20c47423eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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