Merge pull request #204 from hunner/fix_false
(MODULES-3145) Cast values to strings before passing to provider
This commit is contained in:
commit
1fe35c6868
2 changed files with 34 additions and 0 deletions
|
@ -71,6 +71,10 @@ Puppet::Type.newtype(:ini_setting) do
|
||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
|
|
||||||
|
munge do |value|
|
||||||
|
value.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def should_to_s(newvalue)
|
def should_to_s(newvalue)
|
||||||
if (@resource[:show_diff] == :true && Puppet[:show_diff]) then
|
if (@resource[:show_diff] == :true && Puppet[:show_diff]) then
|
||||||
return newvalue
|
return newvalue
|
||||||
|
|
|
@ -268,6 +268,36 @@ subby=bar
|
||||||
)
|
)
|
||||||
end
|
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
|
it "should modify an existing setting with pre/suffix with a different value" do
|
||||||
resource = Puppet::Type::Ini_setting.new(common_params.merge(
|
resource = Puppet::Type::Ini_setting.new(common_params.merge(
|
||||||
:section => 'nonstandard',
|
:section => 'nonstandard',
|
||||||
|
|
Loading…
Reference in a new issue