blob: 9d12d61d3125a7711a7a818a542a4cb854dc3e0f (
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
|
require 'spec_helper'
require 'puppet'
provider_class = Puppet::Type.type(:ini_subsetting).provider(:ruby)
describe provider_class do
include PuppetlabsSpec::Files
let(:tmpfile) { tmpfilename("ini_setting_test") }
let(:common_params) { {
:title => 'ini_setting_ensure_present_test',
:path => tmpfile,
:section => '',
:key_val_separator => '=',
:setting => 'JAVA_ARGS',
} }
def validate_file(expected_content,tmpfile = tmpfile)
File.read(tmpfile).should == expected_content
end
before :each do
File.open(tmpfile, 'w') do |fh|
fh.write(orig_content)
end
end
context "when ensuring that a subsetting is present" do
let(:orig_content) {
<<-EOS
JAVA_ARGS="-Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof"
EOS
}
it "should add a missing subsetting" do
resource = Puppet::Type::Ini_subsetting.new(common_params.merge(
:subsetting => '-Xms', :value => '128m'))
provider = described_class.new(resource)
provider.exists?.should be_nil
provider.create
validate_file(<<-EOS
JAVA_ARGS="-Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof -Xms128m"
EOS
)
end
it "should remove an existing subsetting" do
resource = Puppet::Type::Ini_subsetting.new(common_params.merge(
:subsetting => '-Xmx'))
provider = described_class.new(resource)
provider.exists?.should == "192m"
provider.destroy
validate_file(<<-EOS
JAVA_ARGS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof"
EOS
)
end
it "should modify an existing subsetting" do
resource = Puppet::Type::Ini_subsetting.new(common_params.merge(
:subsetting => '-Xmx', :value => '256m'))
provider = described_class.new(resource)
provider.exists?.should == "192m"
provider.value=('256m')
validate_file(<<-EOS
JAVA_ARGS="-Xmx256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof"
EOS
)
end
end
end
|