X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fopenstacklib%2Fspec%2Ffunctions%2Fos_database_connection_spec.rb;fp=3rdparty%2Fmodules%2Fopenstacklib%2Fspec%2Ffunctions%2Fos_database_connection_spec.rb;h=0000000000000000000000000000000000000000;hb=943dd63ceab3c595cfdff25de2631d5b74f19dc9;hp=6819e7e8f4bd0abc53e6d4782569f82ecaebf8d7;hpb=706621d7a3318aef2d3a0b3665d08a98fdd9a458;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/openstacklib/spec/functions/os_database_connection_spec.rb b/3rdparty/modules/openstacklib/spec/functions/os_database_connection_spec.rb deleted file mode 100644 index 6819e7e8f..000000000 --- a/3rdparty/modules/openstacklib/spec/functions/os_database_connection_spec.rb +++ /dev/null @@ -1,134 +0,0 @@ -require 'spec_helper' - -describe 'os_database_connection' do - - it 'refuses String' do - should run.with_params('foo').\ - and_raise_error(Puppet::ParseError, /Requires an hash/) - end - - it 'refuses Array' do - should run.with_params(['foo']).\ - and_raise_error(Puppet::ParseError, /Requires an hash/) - end - - it 'refuses without at least one argument' do - should run.with_params().\ - and_raise_error(Puppet::ParseError, /Wrong number of arguments/) - end - - it 'refuses too many arguments' do - should run.with_params('foo', 'bar').\ - and_raise_error(Puppet::ParseError, /Wrong number of arguments/) - end - - it 'fails if port is provided with missing host' do - should run.with_params({ - 'dialect' => 'sqlite', - 'database' => '/var/lib/keystone/keystone.db', - 'port' => '3306', - 'charset' => 'utf-8' - }).and_raise_error(Puppet::ParseError, /host is required with port/) - end - - context 'creates the correct connection URI' do - - it 'with all parameters' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'test', - 'username' => 'guest', - 'password' => 's3cr3t', - 'charset' => 'utf-8' - }).and_return('mysql://guest:s3cr3t@127.0.0.1:3306/test?charset=utf-8') - end - - it 'without port' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'database' => 'test', - 'username' => 'guest', - 'password' => 's3cr3t', - 'charset' => 'utf-8' - }).and_return('mysql://guest:s3cr3t@127.0.0.1/test?charset=utf-8') - end - - it 'without host and port' do - should run.with_params({ - 'dialect' => 'sqlite', - 'database' => '/var/lib/keystone/keystone.db', - 'charset' => 'utf-8' - }).and_return('sqlite:////var/lib/keystone/keystone.db?charset=utf-8') - end - - it 'without username and password' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'test', - 'charset' => 'utf-8' - }).and_return('mysql://127.0.0.1:3306/test?charset=utf-8') - end - - it 'with username set to undef' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'test', - 'username' => :undef, - 'charset' => 'utf-8' - }).and_return('mysql://127.0.0.1:3306/test?charset=utf-8') - end - - it 'with username set to an empty string' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'test', - 'username' => '', - 'charset' => 'utf-8' - }).and_return('mysql://127.0.0.1:3306/test?charset=utf-8') - end - - it 'without password' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'test', - 'username' => 'guest', - 'charset' => 'utf-8' - }).and_return('mysql://guest@127.0.0.1:3306/test?charset=utf-8') - end - - it 'with password set to undef' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'test', - 'username' => 'guest', - 'password' => :undef, - 'charset' => 'utf-8' - }).and_return('mysql://guest@127.0.0.1:3306/test?charset=utf-8') - end - - it 'with password set to an empty string' do - should run.with_params({ - 'dialect' => 'mysql', - 'host' => '127.0.0.1', - 'port' => '3306', - 'database' => 'test', - 'username' => 'guest', - 'password' => '', - 'charset' => 'utf-8' - }).and_return('mysql://guest@127.0.0.1:3306/test?charset=utf-8') - end - end -end