diff options
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb index 68bc87eaf8..830c0892d3 100644 --- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -24,6 +24,18 @@ module ActiveRecord end end + def test_database_exists_returns_false_when_the_database_does_not_exist + config = { database: "non_extant_database", adapter: "postgresql" } + assert_not ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.database_exists?(config), + "expected database #{config[:database]} to not exist" + end + + def test_database_exists_returns_true_when_the_database_exists + config = ActiveRecord::Base.configurations["arunit"] + assert ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.database_exists?(config), + "expected database #{config[:database]} to exist" + end + def test_primary_key with_example_table do assert_equal "id", @connection.primary_key("ex") @@ -241,9 +253,11 @@ module ActiveRecord def test_expression_index with_example_table do - @connection.add_index "ex", "mod(id, 10), abs(number)", name: "expression" + expr = "mod(id, 10), abs(number)" + @connection.add_index "ex", expr, name: "expression" index = @connection.indexes("ex").find { |idx| idx.name == "expression" } - assert_equal "mod(id, 10), abs(number)", index.columns + assert_equal expr, index.columns + assert_equal true, @connection.index_exists?("ex", expr, name: "expression") end end |