Skip to content

Commit 81abe84

Browse files
committed
add tests for info messages flush before error
1 parent e604624 commit 81abe84

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/result_test.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,30 @@ class ResultTest < TinyTds::TestCase
670670
@client.execute("EXEC tinytds_TestSeveralPrints").do
671671
assert_equal ['hello 1', 'hello 2', 'hello 3'], messages.map { |e| e.message }, 'message list'
672672
end
673+
674+
it 'should flush info messages before raising error in cases of timeout' do
675+
@client = new_connection timeout: 1, port: 1234, message_handler: Proc.new { |m| messages << m }
676+
action = lambda { @client.execute("print 'hello'; waitfor delay '00:00:02'").do }
677+
messages.clear
678+
assert_raise_tinytds_error(action) do |e|
679+
assert_match %r{timed out}i, e.message, 'ignore if non-english test run'
680+
assert_equal 6, e.severity
681+
assert_equal 20003, e.db_error_number
682+
assert_equal 'hello', messages.first&.message, 'message text'
683+
end
684+
end
685+
686+
it 'should print info messages before raising error in cases of timeout' do
687+
@client = new_connection timeout: 1, port: 1234, message_handler: Proc.new { |m| messages << m }
688+
action = lambda { @client.execute("raiserror('hello', 1, 1) with nowait; waitfor delay '00:00:02'").do }
689+
messages.clear
690+
assert_raise_tinytds_error(action) do |e|
691+
assert_match %r{timed out}i, e.message, 'ignore if non-english test run'
692+
assert_equal 6, e.severity
693+
assert_equal 20003, e.db_error_number
694+
assert_equal 'hello', messages.first&.message, 'message text'
695+
end
696+
end
673697
end
674698

675699
it 'must not raise an error when severity is 10 or less' do

0 commit comments

Comments
 (0)