File: ini_setting_spec.rb

package info (click to toggle)
puppet-module-nova 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,100 kB
  • sloc: ruby: 11,433; python: 38; sh: 10; makefile: 10
file content (53 lines) | stat: -rw-r--r-- 1,805 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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