Projet

Général

Profil

Révision 435a5db2

ID435a5db2a1f93585af6faab1669a880029e81df6
Parent 232c1364
Enfant 817e064b

Ajouté par Steve Traylen il y a environ 3 ans

rspec mock systemd process on docker

On docker rspec the service provider is autodetected as redhat
rather than systemd.

https://tickets.puppetlabs.com/browse/PUP-11167

That causes

```
error during compilation: Parameter enable failed on Service[firewalld]: Provider redhat must have features 'maskable' to set 'enable' to 'mask' (file: /builds/ai/it-puppet-module-nftables/code/spec/fixtures/modules/nftables/manifests/init.pp, line: 186)
```

mock the systemd process so that the systemd provider is used.

Voir les différences:

spec/spec_helper.rb
4 4
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
5 5

  
6 6
RSpec.configure do |c|
7
  c.before do
8
    # select the systemd service provider even when on docker
9
    # https://tickets.puppetlabs.com/browse/PUP-11167
10
    if defined?(facts) && %w[Archlinux RedHat].include?(facts[:os]['family'])
11
      allow(Puppet::FileSystem).to receive(:exist?).and_call_original
12
      allow(Puppet::FileSystem).to receive(:exist?).with('/proc/1/comm').and_return(true)
13
      allow(Puppet::FileSystem).to receive(:read).and_call_original
14
      allow(Puppet::FileSystem).to receive(:read).with('/proc/1/comm').and_return(['systemd'])
15
    end
16
  end
7 17
end
8 18

  
9 19
# puppetlabs_spec_helper will set up coverage if the env variable is set.

Formats disponibles : Unified diff