| 1 |
require 'spec_helper' |
| 2 |
provider_class = Puppet::Type.type(:libvirtd_config).provider(:ini_setting) |
| 3 |
describe provider_class do |
| 4 |
|
| 5 |
it 'should allow setting to be set explicitly' do |
| 6 |
resource = Puppet::Type::Libvirtd_config.new( |
| 7 |
{:name => 'foo', :value => 'bar'} |
| 8 |
) |
| 9 |
provider = provider_class.new(resource) |
| 10 |
expect(provider.section).to eq('') |
| 11 |
expect(provider.setting).to eq('foo') |
| 12 |
end |
| 13 |
|
| 14 |
it 'should quote the value when quote is true' do |
| 15 |
resource = Puppet::Type::Libvirtd_config.new( |
| 16 |
{:name => 'foo', :value => 'baa', :quote => true } |
| 17 |
) |
| 18 |
provider = provider_class.new(resource) |
| 19 |
provider.exists? |
| 20 |
expect(provider.section).to eq('') |
| 21 |
expect(provider.setting).to eq('foo') |
| 22 |
expect(resource[:value]).to eq('"baa"') |
| 23 |
end |
| 24 |
|
| 25 |
it 'should not quote the value when quote is true but the value is quoted' do |
| 26 |
resource = Puppet::Type::Libvirtd_config.new( |
| 27 |
{:name => 'foo', :value => '"baa"', :quote => true } |
| 28 |
) |
| 29 |
provider = provider_class.new(resource) |
| 30 |
provider.exists? |
| 31 |
expect(provider.section).to eq('') |
| 32 |
expect(provider.setting).to eq('foo') |
| 33 |
expect(resource[:value]).to eq('"baa"') |
| 34 |
end |
| 35 |
|
| 36 |
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do |
| 37 |
resource = Puppet::Type::Libvirtd_config.new( |
| 38 |
{:name => 'foo', :value => '<SERVICE DEFAULT>'} |
| 39 |
) |
| 40 |
provider = provider_class.new(resource) |
| 41 |
provider.exists? |
| 42 |
expect(resource[:ensure]).to eq :absent |
| 43 |
end |
| 44 |
|
| 45 |
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value and quote is true' do |
| 46 |
resource = Puppet::Type::Libvirtd_config.new( |
| 47 |
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true} |
| 48 |
) |
| 49 |
provider = provider_class.new(resource) |
| 50 |
provider.exists? |
| 51 |
expect(resource[:ensure]).to eq :absent |
| 52 |
end |
| 53 |
end |