Skip to content

Commit 4aab1b0

Browse files
committed
add print only test
1 parent c886150 commit 4aab1b0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

test/result_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,12 @@ class ResultTest < TinyTds::TestCase
664664
assert_equal 50000, e.db_error_number
665665
end
666666
end
667+
668+
it 'calls the provided message handler for each of a series of `print` messages' do
669+
messages.clear
670+
@client.execute("EXEC tinytds_TestSeveralPrints").do
671+
assert_equal ['hello 1', 'hello 2', 'hello 3'], messages.map { |e| e.message }, 'message list'
672+
end
667673
end
668674

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

test/test_helper.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def load_current_schema
154154
loader.execute(schema_sql).do
155155
loader.execute(sp_sql).do
156156
loader.execute(sp_error_sql).do
157+
loader.execute(sp_several_prints_sql).do
157158
loader.close
158159
true
159160
end
@@ -171,7 +172,13 @@ def drop_sql_sybase
171172
) DROP PROCEDURE tinytds_TestReturnCodes
172173
IF EXISTS(
173174
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestPrintWithError'
174-
) DROP PROCEDURE tinytds_TestPrintWithError|
175+
) DROP PROCEDURE tinytds_TestPrintWithError
176+
IF EXISTS(
177+
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestPrintWithError'
178+
) DROP PROCEDURE tinytds_TestPrintWithError
179+
IF EXISTS(
180+
SELECT 1 FROM sysobjects WHERE type = 'P' AND name = 'tinytds_TestSeveralPrints'
181+
) DROP PROCEDURE tinytds_TestSeveralPrints|
175182
end
176183

177184
def drop_sql_microsoft
@@ -189,7 +196,11 @@ def drop_sql_microsoft
189196
IF EXISTS (
190197
SELECT name FROM sysobjects
191198
WHERE name = 'tinytds_TestPrintWithError' AND type = 'P'
192-
) DROP PROCEDURE tinytds_TestPrintWithError|
199+
) DROP PROCEDURE tinytds_TestPrintWithError
200+
IF EXISTS (
201+
SELECT name FROM sysobjects
202+
WHERE name = 'tinytds_TestSeveralPrints' AND type = 'P'
203+
) DROP PROCEDURE tinytds_TestSeveralPrints|
193204
end
194205

195206
def sp_sql
@@ -206,6 +217,14 @@ def sp_error_sql
206217
RAISERROR('Error following print', 16, 1)|
207218
end
208219

220+
def sp_several_prints_sql
221+
%|CREATE PROCEDURE tinytds_TestSeveralPrints
222+
AS
223+
PRINT 'hello 1'
224+
PRINT 'hello 2'
225+
PRINT 'hello 3'|
226+
end
227+
209228
def find_value(id, column, query_options={})
210229
query_options[:timezone] ||= :utc
211230
sql = "SELECT [#{column}] FROM [datatypes] WHERE [id] = #{id}"

0 commit comments

Comments
 (0)