Files
puppet-neutron/spec/unit/provider/neutron_l2gw_service_config/openstackconfig_spec.rb
Peng Liu d564aee3ac Add support for l2 Gateway
Introduce puppet classes to configure networking-l2gw agent service
Introduce puppet classes to configure networking-l2gw plugin

Implements: blueprint l2gw-service-integration

Change-Id: I1082cbf9665ed9fbb441705a5e2b2aa97aae5d6f
Signed-off-by: Peng Liu <pliu@redhat.com>
2017-03-07 13:02:41 +08:00

75 lines
1.9 KiB
Ruby

$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'openstacklib',
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:neutron_l2gw_service_config).provider(:openstackconfig)
describe provider_class do
it 'should default to the default setting when no other one is specified' do
resource = Puppet::Type::Neutron_l2gw_service_config.new(
{
:name => 'DEFAULT/foo',
:value => 'bar'
}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('DEFAULT')
expect(provider.setting).to eq('foo')
expect(provider.file_path).to eq('/etc/neutron/l2gw_plugin.ini')
end
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Neutron_l2gw_service_config.new(
{
:name => 'dude/foo',
:value => 'bar'
}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('dude')
expect(provider.setting).to eq('foo')
expect(provider.file_path).to eq('/etc/neutron/l2gw_plugin.ini')
end
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
resource = Puppet::Type::Neutron_l2gw_service_config.new(
{:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
it 'should ensure absent when value matches ensure_absent_val' do
resource = Puppet::Type::Neutron_l2gw_service_config.new(
{:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
end