84 lines
2.3 KiB
Ruby
84 lines
2.3 KiB
Ruby
#
|
|
# Copyright (C) 2016 Red Hat Inc. <licensing@redhat.com>
|
|
#
|
|
# Author: Ade Lee <alee@redhat.com>
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
# Unit tests for barbican_api_paste_ini provider class
|
|
#
|
|
$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(:barbican_api_paste_ini).provider(:ini_setting)
|
|
describe provider_class do
|
|
|
|
it 'should default to the default setting when no other one is specified' do
|
|
resource = Puppet::Type::Barbican_api_paste_ini.new(
|
|
{:name => 'DEFAULT/foo', :value => 'bar'}
|
|
)
|
|
provider = provider_class.new(resource)
|
|
expect(provider.section).to eq('DEFAULT')
|
|
expect(provider.setting).to eq('foo')
|
|
end
|
|
|
|
it 'should allow setting to be set explicitly' do
|
|
resource = Puppet::Type::Barbican_api_paste_ini.new(
|
|
{:name => 'dude/whoa', :value => 'bar'}
|
|
)
|
|
provider = provider_class.new(resource)
|
|
expect(provider.section).to eq('dude')
|
|
expect(provider.setting).to eq('whoa')
|
|
end
|
|
|
|
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
|
resource = Puppet::Type::Barbican_api_paste_ini.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::Barbican_api_paste_ini.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
|
|
|