Merge pull request #422 from stevesaliman/master

fixed a quoting problem with the mysql_database provider
This commit is contained in:
Igor Galić 2014-01-25 03:50:23 -08:00
commit c747ea7ab5
2 changed files with 3 additions and 3 deletions

View file

@ -7,7 +7,7 @@ Puppet::Type.type(:mysql_database).provide(:mysql, :parent => Puppet::Provider::
def self.instances
mysql([defaults_file, '-NBe', 'show databases'].compact).split("\n").collect do |name|
attributes = {}
mysql([defaults_file, '-NBe', 'show variables like "%_database"', name].compact).split("\n").each do |line|
mysql([defaults_file, '-NBe', "show variables like '%_database'"].compact).split("\n").each do |line|
k,v = line.split(/\s/)
attributes[k] = v
end

View file

@ -31,7 +31,7 @@ test
Puppet::Util.stubs(:which).with('mysql').returns('/usr/bin/mysql')
File.stubs(:file?).with('/root/.my.cnf').returns(true)
provider.class.stubs(:mysql).with([defaults_file, '-NBe', 'show databases']).returns('new_database')
provider.class.stubs(:mysql).with([defaults_file, '-NBe', 'show variables like "%_database"', 'new_database']).returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF")
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "show variables like '%_database'"]).returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF")
end
let(:instance) { provider.class.instances.first }
@ -40,7 +40,7 @@ test
it 'returns an array of databases' do
provider.class.stubs(:mysql).with([defaults_file, '-NBe', 'show databases']).returns(raw_databases)
raw_databases.each_line do |db|
provider.class.stubs(:mysql).with([defaults_file, '-NBe', 'show variables like "%_database"', db.chomp]).returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF")
provider.class.stubs(:mysql).with([defaults_file, '-NBe', "show variables like '%_database'"]).returns("character_set_database latin1\ncollation_database latin1_swedish_ci\nskip_show_database OFF")
end
databases = provider.class.instances.collect {|x| x.name }
parsed_databases.should match_array(databases)