Skip to content

Commit 8c1841b

Browse files
authored
Fix various tests (#333)
- Remove `database_exists?` method from `CockroachDBAdapter`, the original method is fine. - Exclude a test that will be fixed in Rails 7.2
1 parent 0f9a418 commit 8c1841b

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ group :development, :test do
6262

6363
# Gems used by the ActiveRecord test suite
6464
gem "bcrypt", "~> 3.1.18"
65-
gem "mocha", "~> 1.14.0"
6665
gem "sqlite3", "~> 1.4.4"
6766

6867
gem "minitest", "~> 5.15.0"

lib/active_record/connection_adapters/cockroachdb_adapter.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ def supports_deferrable_constraints?
243243
# @crdb_version = version_num.to_i
244244
# end
245245

246-
def self.database_exists?(config)
247-
!!ActiveRecord::Base.cockroachdb_connection(config)
248-
rescue ActiveRecord::NoDatabaseError
249-
false
250-
end
251-
252246
def initialize(...)
253247
super
254248

test/cases/connection_adapters/type_test.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ module CockroachDB
77
module ConnectionAdapters
88
class TypeTest < ActiveRecord::TestCase
99
fixtures :accounts
10-
class SqliteModel < ActiveRecord::Base
10+
class FakeModel < ActiveRecord::Base
1111
establish_connection(
12-
adapter: "sqlite3",
13-
database: "tmp/some"
12+
adapter: "fake"
1413
)
1514
end
1615
def test_type_can_be_used_with_various_db
@@ -19,8 +18,8 @@ def test_type_can_be_used_with_various_db
1918
ActiveRecord::Type.adapter_name_from(Account)
2019
)
2120
assert_equal(
22-
:sqlite3,
23-
ActiveRecord::Type.adapter_name_from(SqliteModel)
21+
:fake,
22+
ActiveRecord::Type.adapter_name_from(FakeModel)
2423
)
2524
end
2625
end
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
exclude :test_deadlock_raises_Deadlocked_inside_nested_SavepointTransaction, "Causes CI to hand. Skip while debugging."
2-
exclude :test_unserializable_transaction_raises_SerializationFailure_inside_nested_SavepointTransaction, "Causes CI to hand. Skip while debugging."
1+
2+
# > In CRDB SERIALIZABLE, reads block on in-progress writes for
3+
# > as long as those writes are in progress. However, PG does
4+
# > not have this "read block on write" behavior, and so rather
5+
# > than allowing the left-hand-side to execute, it must instead
6+
# > abort that transaction. Both are valid ways to implement SERIALIZABLE.
7+
#
8+
# See discussion: https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/333
9+
message = "SERIALIZABLE transactions are different in CockroachDB."
10+
11+
exclude :test_deadlock_raises_Deadlocked_inside_nested_SavepointTransaction, message
12+
exclude :test_unserializable_transaction_raises_SerializationFailure_inside_nested_SavepointTransaction, message
13+
exclude :test_SerializationFailure_inside_nested_SavepointTransaction_is_recoverable, message
14+
exclude :test_deadlock_inside_nested_SavepointTransaction_is_recoverable, message
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# TODO: Rails 7.2 remove this exclusion
2+
exclude "test_#undefine_attribute_methods_undefines_alias_attribute_methods", "The test will be fixed in 7.2 (https://github.com/rails/rails/commit/a0993f81d0450a191da1ee35282f60fc2899135c)"

0 commit comments

Comments
 (0)