Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get tests to pass locally #3

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Set correct config for MySQL db connection
  • Loading branch information
shioyama committed Jan 31, 2025
commit 5b9b481db45e2f79bcfaa7d912fc00a4e105cb2a
8 changes: 0 additions & 8 deletions test/database.yml

This file was deleted.

19 changes: 14 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def assert_data_loss(record)

persisted_values = record.reload.attributes.slice(*attributes)
refute_equal provided_values, persisted_values
rescue RangeError
rescue ActiveRecord::RangeError, ActiveRecord::StatementInvalid, ActiveModel::RangeError
pass
end

Expand All @@ -33,8 +33,17 @@ def refute_data_loss(record)
end
end

Minitest::Test = MiniTest::Unit::TestCase unless defined?(MiniTest::Test)

database_yml = YAML.load_file(File.expand_path('../database.yml', __FILE__))
ActiveRecord::Base.establish_connection(database_yml['test'])
mysql_host = ENV.fetch("MYSQL_HOST") { "localhost" }
mysql_port = ENV.fetch("MYSQL_PORT") { 3306 }
connection_config = {
adapter: "mysql2",
database: "database_validations",
username: "root",
encoding: "utf8mb4",
strict: false,
host: mysql_host,
port: mysql_port,
}

ActiveRecord::Base.establish_connection(connection_config)
I18n.enforce_available_locales = false