@@ -670,6 +670,30 @@ class ResultTest < TinyTds::TestCase
670
670
@client . execute ( "EXEC tinytds_TestSeveralPrints" ) . do
671
671
assert_equal [ 'hello 1' , 'hello 2' , 'hello 3' ] , messages . map { |e | e . message } , 'message list'
672
672
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
673
697
end
674
698
675
699
it 'must not raise an error when severity is 10 or less' do
0 commit comments