fuel-library/deployment/puppet/heat/spec/classes/heat_db_mysql_spec.rb
Bogdan Dobrelya d14ea2edf3 Sync puppet-heat
17736b2fd726858cb83590f8a8b1d594a087ea44 4.0.0

Partial blueprint merge-openstack-puppet-modules

Change-Id: Icbe9f8c87ea0b6c0a3287c1c36137302bf293009
Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
2014-07-03 13:27:38 +03:00

86 lines
2.0 KiB
Ruby

require 'spec_helper'
describe 'heat::db::mysql' do
let :facts do
{ :osfamily => 'RedHat' }
end
let :params do
{ :password => 's3cr3t',
:dbname => 'heat',
:user => 'heat',
:host => 'localhost',
:charset => 'utf8',
:mysql_module => '0.9'
}
end
shared_examples_for 'heat mysql database' do
context 'when omiting the required parameter password' do
before { params.delete(:password) }
it { expect { should raise_error(Puppet::Error) } }
end
it 'creates a mysql database' do
should contain_mysql__db( params[:dbname] ).with(
:user => params[:user],
:password => params[:password],
:host => params[:host],
:charset => params[:charset],
:require => 'Class[Mysql::Config]'
)
end
end
describe "overriding allowed_hosts param to array" do
let :params do
{
:password => 'heatpass',
:allowed_hosts => ['localhost','%']
}
end
it {should_not contain_heat__db__mysql__host_access("localhost").with(
:user => 'heat',
:password => 'heatpass',
:database => 'heat'
)}
it {should contain_heat__db__mysql__host_access("%").with(
:user => 'heat',
:password => 'heatpass',
:database => 'heat'
)}
end
describe "overriding allowed_hosts param to string" do
let :params do
{
:password => 'heatpass2',
:allowed_hosts => '192.168.1.1'
}
end
it {should contain_heat__db__mysql__host_access("192.168.1.1").with(
:user => 'heat',
:password => 'heatpass2',
:database => 'heat'
)}
end
describe "overriding allowed_hosts param equals to host param " do
let :params do
{
:password => 'heatpass2',
:allowed_hosts => 'localhost'
}
end
it {should_not contain_heat__db__mysql__host_access("localhost").with(
:user => 'heat',
:password => 'heatpass2',
:database => 'heat'
)}
end
end