From 2dd993bfbb6c38cddbe583bdfdbf47a5b2bfa62b Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Tue, 3 Sep 2024 17:56:02 +0200 Subject: [PATCH] details --- bin/console | 2 +- test/cases/adapters/postgresql/postgresql_adapter_test.rb | 8 +++++--- test/cases/helper_cockroachdb.rb | 3 +++ .../ConnectionAdapters/PostgreSQLAdapterTest.rb | 4 +++- test/excludes/PostgresqlRenameTableTest.rb | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/console b/bin/console index eac96606..4bf50179 100755 --- a/bin/console +++ b/bin/console @@ -5,7 +5,7 @@ $:.unshift(File.expand_path("../lib", __dir__)) # require "bundler/setup" # Bundler.require :development -require "active_record" +require "activerecord-cockroachdb-adapter" # This allows playing with the rake task as well. Ex: # # ActiveRecord::Tasks::DatabaseTasks. diff --git a/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/test/cases/adapters/postgresql/postgresql_adapter_test.rb index 6cc88ec5..7bf2e7d6 100644 --- a/test/cases/adapters/postgresql/postgresql_adapter_test.rb +++ b/test/cases/adapters/postgresql/postgresql_adapter_test.rb @@ -25,9 +25,11 @@ def teardown end def test_database_exists_returns_false_when_the_database_does_not_exist - config = { database: "non_extant_database", adapter: "cockroachdb" } - assert_not ActiveRecord::ConnectionAdapters::CockroachDBAdapter.database_exists?(config), - "expected database #{config[:database]} to not exist" + [ { database: "non_extant_database", adapter: "postgresql" }, + { database: "non_extant_database", adapter: "cockroachdb" } ].each do |config| + assert_not ActiveRecord::ConnectionAdapters::CockroachDBAdapter.database_exists?(config), + "expected database #{config[:database]} to not exist" + end end def test_database_exists_returns_true_when_the_database_exists diff --git a/test/cases/helper_cockroachdb.rb b/test/cases/helper_cockroachdb.rb index 672b18da..654c8520 100644 --- a/test/cases/helper_cockroachdb.rb +++ b/test/cases/helper_cockroachdb.rb @@ -26,6 +26,8 @@ def current_adapter?(...) module LoadSchemaHelperExt def load_schema + # TODO: Remove this const_set mess once https://github.com/rails/rails/commit/d5c2ff8345c9d23b7326edb2bbe72b6e86a63140 + # is part of a rails release. old_helper = ActiveRecord::TestCase ActiveRecord.const_set(:TestCase, NoPGSchemaTestCase.new(ActiveRecord::TestCase)) return if ENV['COCKROACH_LOAD_FROM_TEMPLATE'] @@ -196,6 +198,7 @@ def before_teardown if ENV['AR_LOG'] ActiveRecord::Base.logger = Logger.new(STDOUT) ActiveRecord::Base.logger.level = Logger::DEBUG + ActiveRecord::LogSubscriber::IGNORE_PAYLOAD_NAMES.clear ActiveRecord::Base.logger.formatter = proc { |severity, time, progname, msg| th = Thread.current[:name] th = "THREAD=#{th}" if th diff --git a/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb b/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb index fc038b19..386c0948 100644 --- a/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb +++ b/test/excludes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapterTest.rb @@ -11,7 +11,7 @@ exclude :test_exec_insert_default_values_quoted_schema_with_returning_disabled_and_no_sequence_name_given, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" exclude :test_expression_index, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" exclude :test_serial_sequence, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" -exclude :test_database_exists_returns_false_when_the_database_does_not_exist, "Test is reimplemented to use cockroachdb adapter" +exclude :test_database_exists_returns_false_when_the_database_does_not_exist, "Test is reimplemented to use cockroachdb adapter. Still not working in CI, skip until we can triage further" exclude :test_database_exists_returns_true_when_the_database_exists, "Test is reimplemented to use cockroachdb adapter" exclude :test_invalid_index, "The error message differs from PostgreSQL." exclude :test_partial_index_on_column_named_like_keyword, "CockroachDB adds parentheses around the WHERE definition." @@ -20,6 +20,8 @@ exclude :test_pk_and_sequence_for, "The test needs a little rework since the sequence is empty in CRDB" exclude :test_pk_and_sequence_for_with_non_standard_primary_key, "The test needs a little rework since the sequence is empty in CRDB" +exclude :test_pk_and_sequence_for_with_collision_pg_class_oid, "We cannot DELETE on relation pg_depend in CockroachDB. Skipped for now" + # NOTE: The expression `do $$ BEGIN RAISE WARNING 'foo'; END; $$` works with PG, not CRDB. plpgsql_needed = "PL-PGSQL differs in CockroachDB. Not tested yet. See #339" exclude :test_ignores_warnings_when_behaviour_ignore, plpgsql_needed diff --git a/test/excludes/PostgresqlRenameTableTest.rb b/test/excludes/PostgresqlRenameTableTest.rb index 519b304a..bfafb1be 100644 --- a/test/excludes/PostgresqlRenameTableTest.rb +++ b/test/excludes/PostgresqlRenameTableTest.rb @@ -1 +1,2 @@ exclude :test_renaming_a_table_also_renames_the_primary_key_index, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48" +exclude :test_renaming_a_table_also_renames_the_primary_key_sequence, "Skipping until we can triage further. See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/48"