File tree Expand file tree Collapse file tree 5 files changed +25
-12
lines changed Expand file tree Collapse file tree 5 files changed +25
-12
lines changed Original file line number Diff line number Diff line change 12
12
defer1 = client1 . query "SELECT sleep(0.1) as first_query"
13
13
defer1 . callback do |result |
14
14
results << result . first
15
+ client1 . close
15
16
EM . stop_event_loop
16
17
end
17
18
18
19
client2 = Mysql2 ::EM ::Client . new DatabaseCredentials [ 'root' ]
19
20
defer2 = client2 . query "SELECT sleep(0.025) second_query"
20
21
defer2 . callback do |result |
21
22
results << result . first
23
+ client2 . close
22
24
end
23
25
end
24
26
36
38
defer2 = client . query "SELECT sleep(0.025) as second_query"
37
39
defer2 . callback do |r |
38
40
results << r . first
41
+ client . close
39
42
EM . stop_event_loop
40
43
end
41
44
end
51
54
client = Mysql2 ::EM ::Client . new DatabaseCredentials [ 'root' ]
52
55
defer = client . query "SELECT sleep(0.1) as first_query"
53
56
defer . callback do |result |
57
+ client . close
54
58
raise 'some error'
55
59
end
56
60
defer . errback do |err |
Original file line number Diff line number Diff line change 2
2
require 'spec_helper'
3
3
4
4
describe Mysql2 ::Client do
5
- before ( :each ) do
6
- @client = Mysql2 ::Client . new DatabaseCredentials [ 'root' ]
7
- end
8
-
9
5
it "should raise an exception upon connection failure" do
10
6
lambda {
11
7
# The odd local host IP address forces the mysql client library to
@@ -88,6 +84,8 @@ def connect *args
88
84
results [ 1 ] [ 'Value' ] . should_not be_nil
89
85
results [ 1 ] [ 'Value' ] . should be_kind_of ( String )
90
86
results [ 1 ] [ 'Value' ] . should_not be_empty
87
+
88
+ ssl_client . close
91
89
end
92
90
93
91
it "should respond to #close" do
Original file line number Diff line number Diff line change 3
3
4
4
describe Mysql2 ::Error do
5
5
before ( :each ) do
6
- @client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :encoding => "utf8" ) )
7
6
begin
8
- @client . query ( "HAHAHA" )
7
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :encoding => "big5" ) )
8
+ client . query ( "HAHAHA" )
9
9
rescue Mysql2 ::Error => e
10
10
@error = e
11
+ ensure
12
+ client . close
11
13
end
12
14
13
- @client2 = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :encoding => "big5" ) )
14
15
begin
15
- @client2 . query ( "HAHAHA" )
16
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :encoding => "big5" ) )
17
+ client . query ( "HAHAHA" )
16
18
rescue Mysql2 ::Error => e
17
19
@error2 = e
20
+ ensure
21
+ client . close
18
22
end
19
23
end
20
24
Original file line number Diff line number Diff line change 2
2
require 'spec_helper'
3
3
4
4
describe Mysql2 ::Result do
5
- before ( :each ) do
6
- @client = Mysql2 ::Client . new DatabaseCredentials [ 'root' ]
7
- end
8
-
9
5
before ( :each ) do
10
6
@result = @client . query "SELECT 1"
11
7
end
330
326
client2 . query "USE test"
331
327
result = client2 . query ( "SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1" ) . first
332
328
result [ 'enum_test' ] . encoding . should eql ( Encoding . find ( 'us-ascii' ) )
329
+ client2 . close
333
330
end
334
331
335
332
it "should use Encoding.default_internal" do
359
356
client2 . query "USE test"
360
357
result = client2 . query ( "SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1" ) . first
361
358
result [ 'set_test' ] . encoding . should eql ( Encoding . find ( 'us-ascii' ) )
359
+ client2 . close
362
360
end
363
361
364
362
it "should use Encoding.default_internal" do
441
439
client2 . query "USE test"
442
440
result = client2 . query ( "SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1" ) . first
443
441
result [ field ] . encoding . should eql ( Encoding . find ( 'us-ascii' ) )
442
+ client2 . close
444
443
end
445
444
446
445
it "should use Encoding.default_internal" do
Original file line number Diff line number Diff line change 7
7
DatabaseCredentials = YAML . load_file ( 'spec/configuration.yml' )
8
8
9
9
RSpec . configure do |config |
10
+ config . before :each do
11
+ @client = Mysql2 ::Client . new DatabaseCredentials [ 'root' ]
12
+ end
13
+
14
+ config . after :each do
15
+ @client . close
16
+ end
17
+
10
18
config . before ( :all ) do
11
19
client = Mysql2 ::Client . new DatabaseCredentials [ 'root' ]
12
20
client . query %[
You can’t perform that action at this time.
0 commit comments