Skip to content

Commit a1f9ae5

Browse files
committed
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.
1 parent 6d255b7 commit a1f9ae5

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

railties/test/commands/dbconsole_test.rb

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,38 @@ def test_config_with_no_db_config
3838
end
3939

4040
def test_config_with_database_url_only
41-
ENV['DATABASE_URL'] = 'sqlite3://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
41+
ENV['DATABASE_URL'] = 'postgresql://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
4242
app_db_config(nil)
43-
assert_equal Rails::DBConsole.new.config.sort, {
44-
"adapter"=> "sqlite3",
45-
"host"=> "localhost",
46-
"port"=> 9000,
47-
"database"=> "foo_test",
48-
"username"=> "foo",
49-
"password"=> "bar",
50-
"pool"=> "5",
51-
"timeout"=> "3000"
43+
expected = {
44+
"adapter" => "postgresql",
45+
"host" => "localhost",
46+
"port" => 9000,
47+
"database" => "foo_test",
48+
"username" => "foo",
49+
"password" => "bar",
50+
"pool" => "5",
51+
"timeout" => "3000"
5252
}.sort
53+
assert_equal expected, Rails::DBConsole.new.config.sort
5354
end
5455

5556
def test_config_choose_database_url_if_exists
56-
ENV['DATABASE_URL'] = 'sqlite3://foo:bar@dburl:9000/foo_test?pool=5&timeout=3000'
57+
host = "database-url-host.com"
58+
ENV['DATABASE_URL'] = "postgresql://foo:bar@#{host}:9000/foo_test?pool=5&timeout=3000"
5759
sample_config = {
5860
"test" => {
59-
"adapter"=> "sqlite3",
60-
"host"=> "localhost",
61-
"port"=> 9000,
62-
"database"=> "foo_test",
63-
"username"=> "foo",
64-
"password"=> "bar",
65-
"pool"=> "5",
66-
"timeout"=> "3000"
61+
"adapter" => "postgresql",
62+
"host" => "not-the-#{host}",
63+
"port" => 9000,
64+
"database" => "foo_test",
65+
"username" => "foo",
66+
"password" => "bar",
67+
"pool" => "5",
68+
"timeout" => "3000"
6769
}
6870
}
6971
app_db_config(sample_config)
70-
assert_equal Rails::DBConsole.new.config["host"], "dburl"
72+
assert_equal host, Rails::DBConsole.new.config["host"]
7173
end
7274

7375
def test_env

0 commit comments

Comments
 (0)