File: setting_hooks_spec.rb

package info (click to toggle)
puppet 5.5.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,316 kB
  • sloc: ruby: 254,925; sh: 1,608; xml: 219; makefile: 153; sql: 103
file content (27 lines) | stat: -rw-r--r-- 912 bytes parent folder | download | duplicates (2)
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
require 'spec_helper'

describe "setting hooks" do
  let(:confdir) { Puppet[:confdir] }
  let(:environmentpath) { File.expand_path("envdir", confdir) }

  describe "reproducing PUP-3500" do
    let(:productiondir) { File.join(environmentpath, "production") }

    before(:each) do
      FileUtils.mkdir_p(productiondir)
    end

    it "accesses correct directory environment settings after initializing a setting with an on_write hook" do
      expect(Puppet.settings.setting(:certname).call_hook).to eq(:on_write_only) 

      File.open(File.join(confdir, "puppet.conf"), "w:UTF-8") do |f|
        f.puts("environmentpath=#{environmentpath}")
        f.puts("certname=something")
      end

      Puppet.initialize_settings
      production_env = Puppet.lookup(:environments).get(:production)
      expect(Puppet.settings.value(:manifest, production_env)).to eq("#{productiondir}/manifests")
    end
  end
end