Files
puppet-nova/spec/unit/provider/libvirtd_config/ini_setting_spec.rb
Takashi Kajinami 5c819fbe34 Load libraries in a single place
This change refactors how the dependent libraries are loaded during
unit tests, and load the libraries in the base spec_helper to avoid
duplicate and redundant implementations.

Change-Id: I7ee1f07d71cfe6bd08d5255a489f2e6c1045e5c9
2021-12-27 10:23:53 +09:00

54 lines
1.8 KiB
Ruby

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