Projet

Général

Profil

Révision 432af5d3

ID432af5d36e0f433651c598d641f023438cab6fa3
Parent 73ae6061
Enfant 8290c1d2

Ajouté par Nacho Barrientos il y a plus de 3 ans

Make sure that the list of interfaces is mocked

If 'networking' is not removed from the facts, the values declared in
`default_module_facts.yml` win (the fact set contains two keys:
`:networking` and `'networking'`)

This test has always been wrong as the interfaces were never been
mocked and the asserts were based on the contents on the default
module facts, not the test context itself.

The bug is obvious in the Puppet6/CentOS9 combination as there's no
`networking` fact in FacterDB, hence only in that case the fact is
overridden and the test does not pass (as it shouldn't).

This fix makes sure that the fact set in the test context is correct
and also that the test declares the actually expected resources.

Voir les différences:

spec/classes/bridges_spec.rb
9 9
    context "on #{os}" do
10 10
      context 'with bridge interfaces br0 and br1-2' do
11 11
        let(:facts) do
12
          os_facts.merge(
12
          os_facts.tap { |x| x.delete('networking') }.merge(
13 13
            networking:
14 14
              { interfaces:
15 15
                {
......
30 30
          )
31 31
        }
32 32

  
33
        it { is_expected.to contain_nftables__rule('default_fwd-bridge_br1_br1') }
33
        it { is_expected.to contain_nftables__rule('default_fwd-bridge_br1_2_br1_2') }
34 34

  
35 35
        it {
36
          expect(subject).to contain_nftables__rule('default_fwd-bridge_br1_br1').with(
36
          expect(subject).to contain_nftables__rule('default_fwd-bridge_br1_2_br1_2').with(
37 37
            order: '08',
38
            content: 'iifname br1 oifname br1 accept'
38
            content: 'iifname br1-2 oifname br1-2 accept'
39 39
          )
40 40
        }
41 41
      end

Formats disponibles : Unified diff