cookbook-openstack-ops-data.../spec/mariadb-client_spec.rb
Lance Albertson 1633b31586 Improve ChefSpec test speed by enabling caching
This updates all references of let(:chef_run) to cached(:chef_run) to speed up
tests. By doing this, we have to create a new cached(:chef_run) block whenever
we need to adjust node attributes for testing. In addition, add missing spec
file for mysql-client-redhat.

Speed was been improved from 27.66 seconds to 20.78 seconds.

Change-Id: I8c095bb4ca298255e09fd59d0e43878423693636
2019-12-07 17:12:54 -08:00

30 lines
772 B
Ruby

# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-ops-database::mariadb-client' do
include_context 'database-stubs'
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) do
runner.node
end
cached(:chef_run) do
runner.node.override['openstack']['db']['service_type'] = 'mariadb'
runner.converge(described_recipe)
end
it 'includes mariadb client recipes' do
expect(chef_run).to include_recipe('mariadb::client')
end
it do
expect(chef_run).to install_mysql2_chef_gem_mariadb('default').with(gem_version: '0.4.9')
end
it 'installs mariadb python client packages' do
expect(chef_run).to install_package('python3-mysqldb')
end
end
end