Permalink
Browse files

Merge branch 'bug/master/db_notify_import_sql_if_given'

* bug/master/db_notify_import_sql_if_given:
  Only notify Exec to import sql if sql is given

Closes #29
  • Loading branch information...
2 parents 4f02a86 + 0783c74 commit f5f9cc5367ffa182237c7c9275615388a3d08ebe @jeffmccune jeffmccune committed Dec 20, 2011
Showing with 25 additions and 8 deletions.
  1. +5 −2 manifests/db.pp
  2. +20 −6 spec/defines/mysql_db_spec.rb
View
@@ -46,7 +46,10 @@
charset => $charset,
provider => 'mysql',
require => Class['mysql::server'],
- notify => Exec["${name}-import-import"],
+ notify => $sql ? {
+ '' => undef,
+ default => Exec["${name}-import-import"],
+ }
}
database_user{"${user}@${host}":
@@ -68,7 +71,7 @@
command => "/usr/bin/mysql -u ${user} -p${password} -h ${host} ${name} < ${sql}",
logoutput => true,
refreshonly => $enforce_sql ? {
- true => false,
+ true => false,
false => true,
},
}
@@ -2,15 +2,29 @@
describe 'mysql::db', :type => :define do
let(:title) { 'test_db' }
+
let(:params) {
- {'user' => 'testuser',
- 'password' => 'testpass',
- 'enforce_sql' => false,
- 'sql' => 'test_sql',
+ { 'user' => 'testuser',
+ 'password' => 'testpass',
}
}
- it 'should set load of sql script to refreshonly' do
- should create_resource('exec', 'test_db-import-import').with_param('refreshonly', true)
+ it 'should not notify the import sql exec if no sql script was provided' do
+ should contain_database('test_db').without_notify
+ end
+
+ it 'should notify exec to import sql if sql script is given' do
+ params.merge!({'sql' => 'test_sql'})
+ should contain_database('test_db').with_notify('Exec[test_db-import-import]')
+ end
+
+ it 'should only import sql script on creation if not enforcing' do
+ params.merge!({'sql' => 'test_sql', 'enforce_sql' => false})
+ should contain_exec('test_db-import-import').with_refreshonly(true)
+ end
+
+ it 'should import sql script on creation if enforcing' do
+ params.merge!({'sql' => 'test_sql', 'enforce_sql' => true})
+ should contain_exec('test_db-import-import').with_refreshonly(false)
end
end

0 comments on commit f5f9cc5

Please sign in to comment.