From 9c773404a6c20ce0e693cd15fb999c2a78040845 Mon Sep 17 00:00:00 2001 From: Ulysse Buonomo Date: Tue, 3 Sep 2024 22:45:00 +0200 Subject: [PATCH] select failing tests --- .github/workflows/ci.yml | 2 +- CONTRIBUTING.md | 2 ++ test/cases/adapter_test.rb | 2 +- test/cases/dirty_test.rb | 2 +- test/cases/fixtures_test.rb | 4 ++-- test/cases/migration/change_schema_test.rb | 2 +- test/cases/migration/check_constraint_test.rb | 2 +- test/cases/migration/foreign_key_test.rb | 4 ++-- test/cases/migration_test.rb | 12 ++++++------ 9 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8c99ddc..2a2e5637 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,4 +88,4 @@ jobs: done cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure - name: Test - run: bundle exec rake test TESTOPTS='--profile=3 --verbose' + run: bundle exec rake test TESTOPTS='--profile=3 --verbose --name="/FixturesResetPkSequenceTest/"' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index be9aae4b..632d2262 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -151,6 +151,8 @@ This section intent to help you with a checklist. - [x] `def column_definitions(` - [x] `def pk_and_sequence_for(` - [ ] ... +- Check for setups containing `drop_table` in the test suite. + Especially if you have tons of failure, this is likely the cause. ## Execute only tests that run with a connection diff --git a/test/cases/adapter_test.rb b/test/cases/adapter_test.rb index c8ed0a2e..5d394fef 100644 --- a/test/cases/adapter_test.rb +++ b/test/cases/adapter_test.rb @@ -29,7 +29,7 @@ def test_indexes assert !indexes.first.unique assert_equal ["firm_id"], indexes.first.columns ensure - @connection.remove_index(:accounts, name: idx_name) rescue nil + @connection.remove_index(:accounts, name: idx_name, if_exists: true) end # This replaces the same test that's been excluded from diff --git a/test/cases/dirty_test.rb b/test/cases/dirty_test.rb index 3402f0ca..675350da 100644 --- a/test/cases/dirty_test.rb +++ b/test/cases/dirty_test.rb @@ -17,7 +17,7 @@ def test_field_named_field Testings.new.attributes end ensure - ActiveRecord::Base.lease_connection.drop_table :testings rescue nil + ActiveRecord::Base.lease_connection.drop_table :testings, if_exists: true ActiveRecord::Base.clear_cache! end end diff --git a/test/cases/fixtures_test.rb b/test/cases/fixtures_test.rb index 55d43ff0..e3ddfdd0 100644 --- a/test/cases/fixtures_test.rb +++ b/test/cases/fixtures_test.rb @@ -197,7 +197,7 @@ def self.name ActiveRecord::Base.table_name_prefix = old_prefix ActiveRecord::Base.table_name_suffix = old_suffix - ActiveRecord::Base.lease_connection.drop_table :prefix_other_topics_suffix rescue nil + ActiveRecord::Base.lease_connection.drop_table :prefix_other_topics_suffix, if_exists: true end # This replaces the same test that's been excluded from @@ -285,7 +285,7 @@ class FixturesResetPkSequenceTest < ActiveRecord::TestCase # ActiveRecord::TestFixtures#before_setup. def before_setup Account.lease_connection.drop_table :accounts, if_exists: true - Account.lease_connection.exec_query("CREATE SEQUENCE IF NOT EXISTS accounts_id_seq") + Account.lease_connection.exec_query("CREATE SEQUENCE IF NOT EXISTS accounts_id_seq") Account.lease_connection.exec_query(" CREATE TABLE accounts ( id BIGINT PRIMARY KEY DEFAULT nextval('accounts_id_seq'), diff --git a/test/cases/migration/change_schema_test.rb b/test/cases/migration/change_schema_test.rb index b7bec67c..cc14724a 100644 --- a/test/cases/migration/change_schema_test.rb +++ b/test/cases/migration/change_schema_test.rb @@ -17,7 +17,7 @@ def setup end teardown do - connection.drop_table :testings rescue nil + connection.drop_table :testings, if_exists: true ActiveRecord::Base.primary_key_prefix_type = nil ActiveRecord::Base.clear_cache! end diff --git a/test/cases/migration/check_constraint_test.rb b/test/cases/migration/check_constraint_test.rb index 2e199a6a..f9f0eb73 100644 --- a/test/cases/migration/check_constraint_test.rb +++ b/test/cases/migration/check_constraint_test.rb @@ -23,7 +23,7 @@ class Trade < ActiveRecord::Base end teardown do - @connection.drop_table "trades", if_exists: true rescue nil + @connection.drop_table "trades", if_exists: true end if ActiveRecord::Base.lease_connection.supports_validate_constraints? diff --git a/test/cases/migration/foreign_key_test.rb b/test/cases/migration/foreign_key_test.rb index a7241258..75c4731d 100644 --- a/test/cases/migration/foreign_key_test.rb +++ b/test/cases/migration/foreign_key_test.rb @@ -370,8 +370,8 @@ class CompositeForeignKeyTest < ActiveRecord::TestCase end teardown do - @connection.drop_table :astronauts, if_exists: true rescue nil - @connection.drop_table :rockets, if_exists: true rescue nil + @connection.drop_table :astronauts, if_exists: true + @connection.drop_table :rockets, if_exists: true end # OVERRIDE: CockroachDB does not quote the table name. diff --git a/test/cases/migration_test.rb b/test/cases/migration_test.rb index 4b2f639c..70eab8ee 100644 --- a/test/cases/migration_test.rb +++ b/test/cases/migration_test.rb @@ -20,22 +20,22 @@ class MigrationTest < ActiveRecord::TestCase @schema_migration.delete_all_versions %w(things awesome_things prefix_things_suffix p_awesome_things_s).each do |table| - Thing.lease_connection.drop_table(table) rescue nil + Thing.lease_connection.drop_table(table, if_exists: true) end Thing.reset_column_information %w(reminders people_reminders prefix_reminders_suffix).each do |table| - Reminder.lease_connection.drop_table(table) rescue nil + Reminder.lease_connection.drop_table(table, if_exists: true) end Reminder.reset_table_name Reminder.reset_column_information %w(last_name key bio age height wealth birthday favorite_day moment_of_truth male administrator funny).each do |column| - Person.lease_connection.remove_column("people", column) rescue nil + Person.lease_connection.remove_column("people", column, if_exists: true) end - Person.lease_connection.remove_column("people", "first_name") rescue nil - Person.lease_connection.remove_column("people", "middle_name") rescue nil + Person.lease_connection.remove_column("people", "first_name", if_exists: true) + Person.lease_connection.remove_column("people", "middle_name", if_exists: true) Person.lease_connection.add_column("people", "first_name", :string) Person.reset_column_information @@ -90,7 +90,7 @@ def setup end teardown do - Person.lease_connection.drop_table(:delete_me) rescue nil + Person.lease_connection.drop_table(:delete_me, if_exists: true) end # Change expected query count from PostgreSQLAdapter to CockroachDBAdapter.