File: module_spec.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (52 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (3)
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
require 'spec_helper'
require 'tmpdir'

describe "test cron core module" do
  describe command("puppet apply --detailed-exitcodes -e \"cron { 'test' : ensure => present, command => '/bin/true', minute => 3 }\"") do
    its(:exit_status) { should eq 2 }
    its(:stdout) { should match %r{/Stage\[main\]/Main/Cron\[test\]/ensure: created} }

    describe cron do
      it { should have_entry '3 * * * * /bin/true' }
    end
  end

  describe command("puppet apply --detailed-exitcodes -e \"cron { 'test' : ensure => absent }\"") do
    its(:exit_status) { should eq 2 }
    its(:stdout) { should match %r{/Stage\[main\]/Main/Cron\[test\]/ensure: removed} }

    describe cron do
      it { should_not have_entry '3 * * * * /bin/true' }
    end
  end
end

describe "test augeas core module" do
  tmpdir = Dir.mktmpdir('puppet')

  manifest = <<~EOT
  augeas { 'augeas_spec':
    incl    => '#{tmpdir}/puppet.conf',
    lens    => 'Puppet.lns',
    changes => 'set /files/#{tmpdir}/puppet.conf/main/bar qux',
  }
  EOT
  File.open("#{tmpdir}/augeas.pp", 'w') { |f| f.write(manifest) }

  conf = <<~EOT
  [main]
  bar = baz
  EOT
  File.open("#{tmpdir}/puppet.conf", 'w') { |f| f.write(conf) }

  describe "changing config file parameter" do
    describe command("puppet apply --debug --detailed-exitcodes #{tmpdir}/augeas.pp") do
      its(:exit_status) { should eq 2 }
      its(:stdout) { should match %r{/Stage\[main\]/Main/Augeas\[augeas_spec\]/returns: executed successfully} }

      describe file("#{tmpdir}/puppet.conf") do
        its(:content) { should eq "[main]\nbar = qux\n" }
      end
    end
  end
end