Fix bug in subsetting handling for new settings

Our new state variable `@quote_char` was not being initialized
property if you used `ini_subsetting` for a setting that did
not yet exist.  This fixes that bug.
This commit is contained in:
Chris Price 2013-05-28 14:56:57 -07:00
parent d4ccf14d6c
commit cbea5dcd72
2 changed files with 21 additions and 3 deletions

View file

@ -6,7 +6,9 @@ module Util
def initialize(setting_value, subsetting_separator = ' ')
@setting_value = setting_value
@subsetting_separator = subsetting_separator
@quote_char = ""
if @setting_value
unquoted, @quote_char = unquote_setting_value(setting_value)
@subsetting_items = unquoted.scan(Regexp.new("(?:(?:[^\\#{@subsetting_separator}]|\\.)+)")) # an item can contain escaped separator

View file

@ -75,7 +75,6 @@ JAVA_ARGS="-Xmx256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe
:title => 'ini_setting_ensure_present_test',
:path => tmpfile,
:section => 'master',
:key_val_separator => '=',
:setting => 'reports',
} }
@ -101,7 +100,7 @@ reports = foo
)
end
it "should add a new subsetting" do
it "should add a new subsetting when the 'parent' setting already exists" do
resource = Puppet::Type::Ini_subsetting.new(common_params.merge(
:subsetting => 'puppetdb', :subsetting_separator => ','))
provider = described_class.new(resource)
@ -115,5 +114,22 @@ reports = http,foo,puppetdb
)
end
it "should add a new subsetting when the 'parent' setting does not already exist" do
resource = Puppet::Type::Ini_subsetting.new(common_params.merge(
:setting => 'somenewsetting',
:subsetting => 'puppetdb',
:subsetting_separator => ','))
provider = described_class.new(resource)
provider.exists?.should be_nil
provider.value=('')
validate_file(<<-EOS
[master]
reports = http,foo
somenewsetting = puppetdb
EOS
)
end
end
end