Merge pull request #204 from hunner/fix_false

(MODULES-3145) Cast values to strings before passing to provider
This commit is contained in:
Bryan Jen 2016-03-17 16:09:47 -07:00
commit 1fe35c6868
2 changed files with 34 additions and 0 deletions

View file

@ -71,6 +71,10 @@ Puppet::Type.newtype(:ini_setting) do
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value.to_s
end
def should_to_s(newvalue)
if (@resource[:show_diff] == :true && Puppet[:show_diff]) then
return newvalue

View file

@ -268,6 +268,36 @@ subby=bar
)
end
it "should modify an existing setting with a different boolean value" do
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'section1', :setting => 'master', :value => false))
provider = described_class.new(resource)
provider.exists?.should be true
expect(Puppet::Transaction::ResourceHarness.new(nil).evaluate(provider.resource).out_of_sync).to eq(true)
validate_file(<<-EOS
# This is a comment
[section1]
; This is also a comment
foo=foovalue
bar = barvalue
master = false
[section2]
foo= foovalue2
baz=bazvalue
url = http://192.168.1.1:8080
[section:sub]
subby=bar
#another comment
; yet another comment
-nonstandard-
shoes = purple
EOS
)
end
it "should modify an existing setting with pre/suffix with a different value" do
resource = Puppet::Type::Ini_setting.new(common_params.merge(
:section => 'nonstandard',