diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-03-04 13:02:38 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-03-06 15:12:48 +0100 |
commit | 0a5fdcd5ae2f7928ce9ce492c9815ad71f858a9f (patch) | |
tree | 266606a6ffa2b92a57529c724f6875a02c63e1e3 /activerecord/test/cases | |
parent | 854b74242c03b34df6b0107b23361b5c130b9550 (diff) | |
download | rails-0a5fdcd5ae2f7928ce9ce492c9815ad71f858a9f.tar.gz rails-0a5fdcd5ae2f7928ce9ce492c9815ad71f858a9f.tar.bz2 rails-0a5fdcd5ae2f7928ce9ce492c9815ad71f858a9f.zip |
rake db:structure:dump warns when `mysqldump` is not in PATH.
Closes #9518.
The rake task used to fail silently and left an empty `structure.sql`.
It's confusing for users to get to the root of the problem.
The warning message tells them where to look.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/tasks/mysql_rake_test.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/test/cases/tasks/mysql_rake_test.rb b/activerecord/test/cases/tasks/mysql_rake_test.rb index 38b9dd02f0..dadcca5b7f 100644 --- a/activerecord/test/cases/tasks/mysql_rake_test.rb +++ b/activerecord/test/cases/tasks/mysql_rake_test.rb @@ -249,10 +249,21 @@ module ActiveRecord def test_structure_dump filename = "awesome-file.sql" - Kernel.expects(:system).with("mysqldump", "--result-file", filename, "--no-data", "test-db") + Kernel.expects(:system).with("mysqldump", "--result-file", filename, "--no-data", "test-db").returns(true) ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename) end + + def test_warn_when_external_structure_dump_fails + filename = "awesome-file.sql" + Kernel.expects(:system).with("mysqldump", "--result-file", filename, "--no-data", "test-db").returns(false) + + warnings = capture(:stderr) do + ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename) + end + + assert_match(/Could not dump the database structure/, warnings) + end end class MySQLStructureLoadTest < ActiveRecord::TestCase |