Add unit tests for nova_api_paste_ini resource

... and deprecated nova_paste_api_ini resource.

Change-Id: Ia0cba87b1a609839201d06469be1885ebaf250f4
This commit is contained in:
Takashi Kajinami 2020-05-04 03:09:13 +09:00
parent b5c5d7acc3
commit 5f453cd9bd
4 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,29 @@
#
# these tests are a little concerning b/c they are hacking around the
# modulepath, so these tests will not catch issues that may eventually arise
# related to loading these plugins.
# I could not, for the life of me, figure out how to programatcally set the modulepath
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:nova_api_paste_ini).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Nova_api_paste_ini.new(
{:name => 'dude/foo', :value => 'bar'}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('dude')
expect(provider.setting).to eq('foo')
end
end

View File

@ -0,0 +1,29 @@
#
# these tests are a little concerning b/c they are hacking around the
# modulepath, so these tests will not catch issues that may eventually arise
# related to loading these plugins.
# I could not, for the life of me, figure out how to programatcally set the modulepath
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:nova_paste_api_ini).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Nova_paste_api_ini.new(
{:name => 'dude/foo', :value => 'bar'}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('dude')
expect(provider.setting).to eq('foo')
end
end

View File

@ -0,0 +1,24 @@
require 'puppet'
require 'puppet/type/nova_api_paste_ini'
describe 'Puppet::Type.type(:nova_api_paste_ini)' do
before :each do
@nova_api_paste_ini = Puppet::Type.type(:nova_api_paste_ini).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@nova_api_paste_ini[:value] = 'bar'
expect(@nova_api_paste_ini[:value]).to eq('bar')
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'nova-common')
catalog.add_resource package, @nova_api_paste_ini
dependency = @nova_api_paste_ini.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@nova_api_paste_ini)
expect(dependency[0].source).to eq(package)
end
end

View File

@ -0,0 +1,24 @@
require 'puppet'
require 'puppet/type/nova_paste_api_ini'
describe 'Puppet::Type.type(:nova_paste_api_ini)' do
before :each do
@nova_paste_api_ini = Puppet::Type.type(:nova_paste_api_ini).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@nova_paste_api_ini[:value] = 'bar'
expect(@nova_paste_api_ini[:value]).to eq('bar')
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
package = Puppet::Type.type(:package).new(:name => 'nova-common')
catalog.add_resource package, @nova_paste_api_ini
dependency = @nova_paste_api_ini.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@nova_paste_api_ini)
expect(dependency[0].source).to eq(package)
end
end