Files
puppet-nova/spec/unit/provider/libvirtd_config/ini_setting_spec.rb
Takashi Kajinami 26dbd52717 Libvirt: quote config parameters in resource types
This change implements the quote parameter in libvirtd_config and
virtlogd_config, so that we can quote the value by that simple
parameter instead of implementing a logic in each manifests.

Also, with this change libvirtd_config and virtlogd_config supports
$::os_service_default, so that we can define absence of parameters more
easily.

Depends-on: https://review.opendev.org/792735
Change-Id: I3030ca34088019be932a9cc33344f7fb473a9aea
2021-06-22 16:13:52 +05:30

70 lines
2.2 KiB
Ruby

#
# these tests are a little concerning b/c they are hacking around the
# modulepath, so these tests will not catch issues that may eventually arise
# related to loading these plugins.
# I could not, for the life of me, figure out how to programatcally set the modulepath
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:libvirtd_config).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Libvirtd_config.new(
{:name => 'foo', :value => 'bar'}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('')
expect(provider.setting).to eq('foo')
end
it 'should quote the value when quote is true' do
resource = Puppet::Type::Libvirtd_config.new(
{:name => 'foo', :value => 'baa', :quote => true }
)
provider = provider_class.new(resource)
provider.exists?
expect(provider.section).to eq('')
expect(provider.setting).to eq('foo')
expect(resource[:value]).to eq('"baa"')
end
it 'should not quote the value when quote is true but the value is quoted' do
resource = Puppet::Type::Libvirtd_config.new(
{:name => 'foo', :value => '"baa"', :quote => true }
)
provider = provider_class.new(resource)
provider.exists?
expect(provider.section).to eq('')
expect(provider.setting).to eq('foo')
expect(resource[:value]).to eq('"baa"')
end
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
resource = Puppet::Type::Libvirtd_config.new(
{:name => 'foo', :value => '<SERVICE DEFAULT>'}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value and quote is true' do
resource = Puppet::Type::Libvirtd_config.new(
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
end