diff --git a/test/cases/create_unlogged_tables_test.rb b/test/cases/create_unlogged_tables_test.rb index 2895393..993a06a 100644 --- a/test/cases/create_unlogged_tables_test.rb +++ b/test/cases/create_unlogged_tables_test.rb @@ -11,7 +11,6 @@ module ActiveRecord module CockroachDB class UnloggedTablesTest < ActiveRecord::PostgreSQLTestCase - include SchemaDumpingHelper TABLE_NAME = "things" LOGGED_FIELD = "relpersistence" @@ -24,24 +23,18 @@ class Thing < ActiveRecord::Base self.table_name = TABLE_NAME end - def setup - @connection = ActiveRecord::Base.lease_connection - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = false - end - - teardown do - @connection.drop_table TABLE_NAME, if_exists: true - ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = false - end - # Cockroachdb ignores the UNLOGGED specifier. # https://github.com/cockroachdb/cockroach/issues/56827 def test_unlogged_in_test_environment_when_unlogged_setting_enabled + @original_create_unlogged_tables = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = true + connection = ActiveRecord::Base.lease_connection - @connection.create_table(TABLE_NAME) do |t| + connection.create_table(TABLE_NAME) do |t| end - assert_equal @connection.execute(LOGGED_QUERY).first[LOGGED_FIELD], LOGGED + assert_equal connection.execute(LOGGED_QUERY).first[LOGGED_FIELD], LOGGED + ensure + ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.create_unlogged_tables = @original_create_unlogged_tables end end end