Skip to content

Commit 264c892

Browse files
committed
this fix is temporary will replace it in next sweep
1 parent 953b00f commit 264c892

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/test_helper.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,20 @@
2828
db_file = File.join(Dir.tmpdir, "closure_tree_test_#{SecureRandom.hex}.sqlite3")
2929
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: db_file)
3030
end
31+
elsif database_url.start_with?('mysql2://')
32+
# Parse MySQL URL: mysql2://root:root@0/closure_tree_test
33+
# The @0 means localhost in GitHub Actions
34+
fixed_url = database_url.gsub('@0/', '@127.0.0.1/')
35+
ActiveRecord::Base.establish_connection(fixed_url)
36+
elsif database_url.start_with?('postgres://')
37+
# Parse PostgreSQL URL: postgres://closure_tree:closure_tree@0/closure_tree_test
38+
# The @0 means localhost in GitHub Actions
39+
fixed_url = database_url.gsub('@0/', '@127.0.0.1/')
40+
# PostgreSQL adapter expects 'postgresql://' not 'postgres://'
41+
fixed_url = fixed_url.gsub('postgres://', 'postgresql://')
42+
ActiveRecord::Base.establish_connection(fixed_url)
3143
else
32-
# For MySQL and PostgreSQL, use the URL directly
44+
# For other database URLs, use directly
3345
ActiveRecord::Base.establish_connection(database_url)
3446
end
3547

0 commit comments

Comments
 (0)