File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ require "#{ File . dirname ( __FILE__ ) } /helper"
2
+
3
+ Mysqlplus ::Test . prepare!
4
+
5
+ class ConnectionPoolTest < ActiveSupport ::TestCase
6
+
7
+ test "should not establish connections in a lazy manner when warmed up" do
8
+ ActiveRecord ::Base . connection_pool . expects ( :checkout_new_connection ) . never
9
+ 5 . times do
10
+ ActiveRecord ::Base . connection_pool . checkout
11
+ end
12
+ end
13
+
14
+ end
Original file line number Diff line number Diff line change
1
+ require "#{ File . dirname ( __FILE__ ) } /../helper"
2
+
3
+ Mysqlplus ::Test . prepare!
4
+
5
+ class ResultTest < ActiveSupport ::TestCase
6
+
7
+ def teardown
8
+ ActiveRecord ::Base . clear_all_connections!
9
+ ActiveRecord ::Base . establish_connection ( Mysqlplus ::Test ::CONNECTION_SPEC )
10
+ super
11
+ end
12
+
13
+ test "should be able to raise exceptions from the background Thread" do
14
+ assert_raises ( StandardError ) do
15
+ ActiveRecord ::Deferrable ::Result . new do
16
+ raise StandardError
17
+ end . to_s
18
+ end
19
+ end
20
+
21
+ test "should release the checked out connection for the background Thread at all times" do
22
+ ActiveRecord ::Base . connection_pool . expects ( :release_connection ) . once
23
+ ActiveRecord ::Deferrable ::Result . new do
24
+ raise StandardError
25
+ end
26
+ end
27
+
28
+ test "should only block when an immediate result is required" do
29
+ ActiveRecord ::Deferrable ::Result . any_instance . expects ( :validate! ) . never
30
+ ActiveRecord ::Deferrable ::Result . new do
31
+ sleep ( 5 )
32
+ end
33
+ end
34
+
35
+ end
You can’t perform that action at this time.
0 commit comments