Browse files

Fix DB Console tests

The build is broken: https://travis-ci.org/rails/rails/builds/15824530

This commit fixes it.

The problem: Sqlite expects the `database` part to be an absolute path. That prompted this change to be committed to master: fbb79b5

This change provides correct behavior. Unfortunately tests were introduced in 971d510 that were relying on the incorrect behavior. We can avoid the fix by changing to another database url such as `mysql` or `postgresql`

In addition to fixing the failure, the assertions are changed so that the "expected" value comes before "actual" value.
  • Loading branch information...
1 parent 6d255b7 commit a1f9ae5eb8b3ff6fd2f55f6518d220de1838e74f @schneems schneems committed Dec 21, 2013
Showing with 22 additions and 20 deletions.
  1. +22 −20 railties/test/commands/dbconsole_test.rb
View
42 railties/test/commands/dbconsole_test.rb
@@ -38,36 +38,38 @@ def test_config_with_no_db_config
end
def test_config_with_database_url_only
- ENV['DATABASE_URL'] = 'sqlite3://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
+ ENV['DATABASE_URL'] = 'postgresql://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
app_db_config(nil)
- assert_equal Rails::DBConsole.new.config.sort, {
- "adapter"=> "sqlite3",
- "host"=> "localhost",
- "port"=> 9000,
- "database"=> "foo_test",
- "username"=> "foo",
- "password"=> "bar",
- "pool"=> "5",
- "timeout"=> "3000"
+ expected = {
+ "adapter" => "postgresql",
+ "host" => "localhost",
+ "port" => 9000,
+ "database" => "foo_test",
+ "username" => "foo",
+ "password" => "bar",
+ "pool" => "5",
+ "timeout" => "3000"
}.sort
+ assert_equal expected, Rails::DBConsole.new.config.sort
end
def test_config_choose_database_url_if_exists
- ENV['DATABASE_URL'] = 'sqlite3://foo:bar@dburl:9000/foo_test?pool=5&timeout=3000'
+ host = "database-url-host.com"
+ ENV['DATABASE_URL'] = "postgresql://foo:bar@#{host}:9000/foo_test?pool=5&timeout=3000"
sample_config = {
"test" => {
- "adapter"=> "sqlite3",
- "host"=> "localhost",
- "port"=> 9000,
- "database"=> "foo_test",
- "username"=> "foo",
- "password"=> "bar",
- "pool"=> "5",
- "timeout"=> "3000"
+ "adapter" => "postgresql",
+ "host" => "not-the-#{host}",
+ "port" => 9000,
+ "database" => "foo_test",
+ "username" => "foo",
+ "password" => "bar",
+ "pool" => "5",
+ "timeout" => "3000"
}
}
app_db_config(sample_config)
- assert_equal Rails::DBConsole.new.config["host"], "dburl"
+ assert_equal host, Rails::DBConsole.new.config["host"]
end
def test_env

0 comments on commit a1f9ae5

Please sign in to comment.