|
| 1 | +require "cases/sqlserver_helper" |
| 2 | +require "rack" |
| 3 | + |
| 4 | +module ActiveRecord |
| 5 | + module ConnectionAdapters |
| 6 | + class ConnectionManagementTest < ActiveRecord::TestCase |
| 7 | + |
| 8 | + COERCED_TESTS = [:test_connection_pool_per_pid] |
| 9 | + # Until that patch is made to rails we are preventing this test from running in this gem. |
| 10 | + |
| 11 | + include SqlserverCoercedTest |
| 12 | + |
| 13 | + #https://www.ruby-forum.com/topic/4221299 |
| 14 | + def test_coerced_connection_pool_per_pid |
| 15 | + return skip('must support fork') unless Process.respond_to?(:fork) |
| 16 | + |
| 17 | + object_id = ActiveRecord::Base.connection.object_id |
| 18 | + |
| 19 | + rd, wr = IO.pipe |
| 20 | + |
| 21 | + # #https://www.ruby-forum.com/topic/4221299 |
| 22 | + # puts "rd.internal_encoding:#{rd.internal_encoding}\nrd.external_encoding:#{rd.external_encoding}" |
| 23 | + # puts "wr.internal_encoding:#{wr.internal_encoding}\nwr.external_encoding:#{wr.external_encoding}" |
| 24 | + # # rd.internal_encoding: |
| 25 | + # # rd.external_encoding:UTF-8 |
| 26 | + # # wr.internal_encoding: |
| 27 | + # # wr.external_encoding:UTF-8 |
| 28 | + |
| 29 | + |
| 30 | + rd.binmode |
| 31 | + wr.binmode |
| 32 | + |
| 33 | + # ERROR |
| 34 | + # marshal data too short |
| 35 | + # test/cases/connection_management_test_sqlserver.rb:43:in `load' |
| 36 | + # test/cases/connection_management_test_sqlserver.rb:43:in `test_coerced_connection_pool_per_pid' |
| 37 | + |
| 38 | + |
| 39 | + # /Users/acarey/code/nextgear/sqlserver/annaswims/activerecord-sqlserver-adapter/test/cases/connection_management_test_sqlserver.rb:41:in `write': "\x98" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) |
| 40 | + # from /Users/acarey/code/nextgear/sqlserver/annaswims/activerecord-sqlserver-adapter/test/cases/connection_management_test_sqlserver.rb:41:in `block in test_coerced_connection_pool_per_pid' |
| 41 | + # from /Users/acarey/code/nextgear/sqlserver/annaswims/activerecord-sqlserver-adapter/test/cases/connection_management_test_sqlserver.rb:38:in `fork' |
| 42 | + # from /Users/acarey/code/nextgear/sqlserver/annaswims/activerecord-sqlserver-adapter/test/cases/connection_management_test_sqlserver.rb:38:in `test_coerced_connection_pool_per_pid' |
| 43 | + pid = fork { |
| 44 | + rd.close |
| 45 | + wr.write Marshal.dump ActiveRecord::Base.connection.object_id |
| 46 | + wr.close |
| 47 | + exit! |
| 48 | + } |
| 49 | + |
| 50 | + wr.close |
| 51 | + |
| 52 | + Process.waitpid pid |
| 53 | + assert_not_equal object_id, Marshal.load(rd.read) |
| 54 | + rd.close |
| 55 | + end |
| 56 | + end |
| 57 | + end |
| 58 | +end |
0 commit comments