module-puppetlabs-mysql/spec/acceptance/mysql_server_root_password_spec.rb
Hunter Haugen 0aed9e07f7 Adding beaker-rspec test files
These tests are more or less parity with the rspec-system tests, though
dependent on a few patches that still have to make it into beaker and
beaker-rspec
2013-12-06 14:52:41 -08:00

60 lines
1.5 KiB
Ruby

require 'spec_helper_acceptance'
describe 'mysql::server::root_password class' do
describe 'reset' do
it 'shuts down mysql' do
pp = <<-EOS
class { 'mysql::server': service_enabled => false }
EOS
apply_manifest(pp, :catch_failures => true)
end
it 'deletes the /root/.my.cnf password' do
shell('rm -rf /root/.my.cnf')
end
it 'deletes all databases' do
case fact('osfamily')
when 'RedHat'
shell('rm -rf `grep datadir /etc/my.cnf | cut -d" " -f 3`/*')
when 'Debian'
shell('rm -rf `grep datadir /etc/mysql/my.cnf | cut -d" " -f 3`/*')
shell('mysql_install_db')
end
end
it 'starts up mysql' do
pp = <<-EOS
class { 'mysql::server': service_enabled => true }
EOS
puppet_apply(pp, :catch_failures => true)
end
end
describe 'when unset' do
it 'should work' do
pp = <<-EOS
class { 'mysql::server': root_password => 'test' }
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
end
describe 'when set' do
it 'should work' do
pp = <<-EOS
class { 'mysql::server': root_password => 'new', old_root_password => 'test' }
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
end
end
end