diff options
author | Chris Price <chris@puppetlabs.com> | 2013-03-25 11:00:41 -0700 |
---|---|---|
committer | Chris Price <chris@puppetlabs.com> | 2013-03-25 11:00:41 -0700 |
commit | e824ab2abae16e97f9a19d21580d6825c4bf705e (patch) | |
tree | 0a6655cc785d224cd186988101beb68c0556036b /spec/unit/puppet/provider | |
parent | 8064df6d004b7e24104c7899053a5c8627c35e1b (diff) | |
parent | 4351d8b9c8dac40f0f733fd7622d655241f113ba (diff) | |
download | puppet-inifile-e824ab2abae16e97f9a19d21580d6825c4bf705e.tar.gz puppet-inifile-e824ab2abae16e97f9a19d21580d6825c4bf705e.tar.bz2 |
Merge pull request #29 from kbrezina/subsetting
Added 'ini_subsetting' custom resource type
Diffstat (limited to 'spec/unit/puppet/provider')
-rw-r--r-- | spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb b/spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb new file mode 100644 index 0000000..9d12d61 --- /dev/null +++ b/spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb @@ -0,0 +1,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 |