diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb index e5fcfd5..88a90cc 100644 --- a/spec/acceptance/mysql_backup_spec.rb +++ b/spec/acceptance/mysql_backup_spec.rb @@ -1,18 +1,9 @@ require 'spec_helper_acceptance' require 'puppet' require 'puppet/util/package' +require_relative './mysql_helper.rb' describe 'mysql::server::backup class' do - - def pre_run - apply_manifest("class { 'mysql::server': root_password => 'password' }", :catch_failures => true) - @mysql_version = (on default, 'mysql --version').output.chomp.match(/\d+\.\d+\.\d+/)[0] - end - - def version_is_greater_than(version) - return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0 - end - context 'should work with no errors' do it 'when configuring mysql backups' do pp = <<-EOS diff --git a/spec/acceptance/mysql_helper.rb b/spec/acceptance/mysql_helper.rb new file mode 100644 index 0000000..7a5dd57 --- /dev/null +++ b/spec/acceptance/mysql_helper.rb @@ -0,0 +1,8 @@ + def pre_run + apply_manifest("class { 'mysql::server': root_password => 'password' }", :catch_failures => true) + @mysql_version = (on default, 'mysql --version').output.chomp.match(/\d+\.\d+\.\d+/)[0] + end + + def version_is_greater_than(version) + return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0 + end diff --git a/spec/acceptance/types/mysql_grant_spec.rb b/spec/acceptance/types/mysql_grant_spec.rb index b985c63..ccf2b27 100644 --- a/spec/acceptance/types/mysql_grant_spec.rb +++ b/spec/acceptance/types/mysql_grant_spec.rb @@ -1,10 +1,12 @@ require 'spec_helper_acceptance' +require 'puppet' +require 'puppet/util/package' +require_relative '../mysql_helper.rb' describe 'mysql_grant' do - before(:all) do pp = <<-EOS - class { 'mysql::server': + class { 'mysql::server': root_password => 'password', } EOS @@ -484,7 +486,10 @@ describe 'mysql_grant' do end it 'should fail with fqdn' do - expect(shell("mysql -NBe \"SHOW GRANTS FOR test@fqdn.com\"", { :acceptable_exit_codes => 1}).stderr).to match(/There is no such grant defined for user 'test' on host 'fqdn.com'/) + pre_run + if ! version_is_greater_than('5.7.0') + expect(shell("mysql -NBe \"SHOW GRANTS FOR test@fqdn.com\"", { :acceptable_exit_codes => 1}).stderr).to match(/There is no such grant defined for user 'test' on host 'fqdn.com'/) + end end it 'finds ipv4' do shell("mysql -NBe \"SHOW GRANTS FOR 'test'@'192.168.5.7'\"") do |r|