summaryrefslogtreecommitdiff
path: root/spec/defines/init_spec.rb
blob: 172929abf2e51edb82bd115e9d872bd06705b041 (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
require 'spec_helper'

describe 'concat' do
  basedir = '/var/lib/puppet/concat'
  let(:title) { '/etc/foo.bar' }
  let(:facts) { {
    :concat_basedir => '/var/lib/puppet/concat',
    :id             => 'root',
  } }
  let :pre_condition do
    'include concat::setup'
  end

  directories = [
    "#{basedir}/_etc_foo.bar",
    "#{basedir}/_etc_foo.bar/fragments",
  ]

  directories.each do |dirs|
    it do
      should contain_file(dirs).with({
        'ensure'  => 'directory',
        'backup'  => 'puppet',
        'group'   => 0,
        'mode'    => '0644',
        'owner'   => 'root',
      })
    end
  end

  files = [
    "/etc/foo.bar",
    "#{basedir}/_etc_foo.bar/fragments.concat",
  ]

  files.each do |file|
    it do
      should contain_file(file).with({
        'ensure'  => 'present',
        'backup'  => 'puppet',
        'group'   => 0,
        'mode'    => '0644',
        'owner'   => 'root',
      })
    end
  end

  it do
    should contain_exec("concat_/etc/foo.bar").with_command(
      "#{basedir}/bin/concatfragments.sh " +
      "-o #{basedir}/_etc_foo.bar/fragments.concat.out " +
      "-d #{basedir}/_etc_foo.bar   "
    )
  end
end

describe 'concat' do

  basedir = '/var/lib/puppet/concat'
  let(:title) { 'foobar' }
  let(:target) { '/etc/foo.bar' }
  let(:facts) { {
    :concat_basedir => '/var/lib/puppet/concat',
    :id             => 'root',
  } }
  let :pre_condition do
    'include concat::setup'
  end

  directories = [
    "#{basedir}/foobar",
    "#{basedir}/foobar/fragments",
  ]

  directories.each do |dirs|
    it do
      should contain_file(dirs).with({
        'ensure'  => 'directory',
        'backup'  => 'puppet',
        'group'   => 0,
        'mode'    => '0644',
        'owner'   => 'root',
      })
    end
  end

  files = [
    "foobar",
    "#{basedir}/foobar/fragments.concat",
  ]

  files.each do |file|
    it do
      should contain_file(file).with({
        'ensure'  => 'present',
        'backup'  => 'puppet',
        'group'   => 0,
        'mode'    => '0644',
        'owner'   => 'root',
      })
    end
  end

  it do
    should contain_exec("concat_foobar").with_command(
      "#{basedir}/bin/concatfragments.sh " +
      "-o #{basedir}/foobar/fragments.concat.out " +
      "-d #{basedir}/foobar   "
    )
  end


end

# vim:sw=2:ts=2:expandtab:textwidth=79