2014-01-24 15:00:19 +00:00
|
|
|
# encoding: UTF-8
|
|
|
|
require_relative 'spec_helper'
|
|
|
|
require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'database'
|
2013-06-07 11:37:01 -07:00
|
|
|
|
2014-02-20 18:28:28 +00:00
|
|
|
describe 'openstack-common::default' do
|
|
|
|
describe 'Openstack Database' do
|
|
|
|
let(:runner) { ChefSpec::Runner.new(CHEFSPEC_OPTS) }
|
|
|
|
let(:node) { runner.node }
|
|
|
|
let(:chef_run) { runner.converge(described_recipe) }
|
|
|
|
let(:subject) { Object.new.extend(Openstack) }
|
2013-06-07 11:37:01 -07:00
|
|
|
|
2014-02-20 18:28:28 +00:00
|
|
|
include_context 'library-stubs'
|
2013-06-07 11:37:01 -07:00
|
|
|
|
2014-02-20 18:28:28 +00:00
|
|
|
describe '#db_create_with_user' do
|
|
|
|
before do
|
2014-07-29 09:59:30 -05:00
|
|
|
allow(subject).to receive(:include_recipe)
|
2014-02-20 18:28:28 +00:00
|
|
|
.with('database::mysql')
|
|
|
|
.and_return('')
|
|
|
|
end
|
2013-06-07 11:37:01 -07:00
|
|
|
|
2014-02-20 18:28:28 +00:00
|
|
|
it 'returns nil when no such service was found' do
|
|
|
|
expect(
|
|
|
|
subject.db_create_with_user('nonexisting', 'user', 'pass')
|
|
|
|
).to be_nil
|
|
|
|
end
|
2013-06-07 11:37:01 -07:00
|
|
|
|
2014-02-20 18:28:28 +00:00
|
|
|
it 'returns db info and creates database with user when service found' do
|
2014-07-29 09:59:30 -05:00
|
|
|
allow(subject).to receive(:database).and_return({})
|
|
|
|
allow(subject).to receive(:database_user).and_return({})
|
2014-02-20 18:28:28 +00:00
|
|
|
result = subject.db_create_with_user('compute', 'user', 'pass')
|
|
|
|
expect(result['host']).to eq('127.0.0.1')
|
|
|
|
expect(result['port']).to eq('3306')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates database' do
|
2014-07-11 16:23:38 -05:00
|
|
|
skip 'TODO: test this LWRP'
|
2014-02-20 18:28:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates database user' do
|
2014-07-11 16:23:38 -05:00
|
|
|
skip 'TODO: test this LWRP'
|
2014-02-20 18:28:28 +00:00
|
|
|
end
|
2013-06-07 11:37:01 -07:00
|
|
|
|
2014-02-20 18:28:28 +00:00
|
|
|
it 'grants privs to database user' do
|
2014-07-11 16:23:38 -05:00
|
|
|
skip 'TODO: test this LWRP'
|
2014-02-20 18:28:28 +00:00
|
|
|
end
|
2013-06-07 11:37:01 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|