File: directory_environments_spec.rb

package info (click to toggle)
puppet-agent 8.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 27,392 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (68 lines) | stat: -rw-r--r-- 2,317 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
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
require 'spec_helper'

describe "directory environments" do
  let(:args) { ['--configprint', 'modulepath', '--environment', 'direnv'] }
  let(:puppet) { Puppet::Application[:apply] }

  context "with a single directory environmentpath" do
    before(:each) do
      environmentdir = PuppetSpec::Files.tmpdir('envpath')
      Puppet[:environmentpath] = environmentdir
      FileUtils.mkdir_p(environmentdir + "/direnv/modules")
    end

    it "config prints the environments modulepath" do
      Puppet.settings.initialize_global_settings(args)
      expect {
        puppet.run
      }.to exit_with(0)
       .and output(%r{/direnv/modules}).to_stdout
    end

    it "config prints the cli --modulepath despite environment" do
      args << '--modulepath' << '/completely/different'
      Puppet.settings.initialize_global_settings(args)
      expect {
        puppet.run
      }.to exit_with(0)
       .and output(%r{/completely/different}).to_stdout
    end

    it 'given an 8.3 style path on Windows, will config print an expanded path',
      :if => Puppet::Util::Platform.windows? do
      pending("GH runners seem to have disabled 8.3 support")

      # ensure an 8.3 style path is set for environmentpath
      shortened = Puppet::Util::Windows::File.get_short_pathname(Puppet[:environmentpath])
      expanded = Puppet::FileSystem.expand_path(shortened)

      Puppet[:environmentpath] = shortened
      expect(Puppet[:environmentpath]).to match(/~/)

      Puppet.settings.initialize_global_settings(args)
      expect {
        puppet.run
      }.to exit_with(0)
       .and output(a_string_matching(expanded)).to_stdout
    end
  end

  context "with an environmentpath having multiple directories" do
    let(:args) { ['--configprint', 'modulepath', '--environment', 'otherdirenv'] }

    before(:each) do
      envdir1 = File.join(Puppet[:confdir], 'env1')
      envdir2 = File.join(Puppet[:confdir], 'env2')
      Puppet[:environmentpath] = [envdir1, envdir2].join(File::PATH_SEPARATOR)
      FileUtils.mkdir_p(envdir2 + "/otherdirenv/modules")
    end

    it "config prints a directory environment modulepath" do
      Puppet.settings.initialize_global_settings(args)
      expect {
        puppet.run
      }.to exit_with(0)
       .and output(%r{otherdirenv/modules}).to_stdout
    end
  end
end