Skip to content

Commit

Permalink
Testing timeouts work as expected and not across sql batches.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Nov 19, 2010
1 parent 78dedc6 commit 7c256b3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,29 @@ class ClientTest < TinyTds::TestCase
assert_nothing_raised { client.execute('SELECT 1 AS [one]').do }
end

should 'not timeout per sql batch when not under transaction' do
client = TinyTds::Client.new(connection_options.merge(:timeout => 2))
assert_nothing_raised do
client.execute("WaitFor Delay '00:00:01'").do
client.execute("WaitFor Delay '00:00:01'").do
client.execute("WaitFor Delay '00:00:01'").do
end
end

should 'not timeout per sql batch when under transaction' do
client = TinyTds::Client.new(connection_options.merge(:timeout => 2))
begin
client.execute("BEGIN TRANSACTION").do
assert_nothing_raised do
client.execute("WaitFor Delay '00:00:01'").do
client.execute("WaitFor Delay '00:00:01'").do
client.execute("WaitFor Delay '00:00:01'").do
end
ensure
client.execute("COMMIT TRANSACTION").do
end
end

should 'raise TinyTds exception with wrong :username' do
options = connection_options.merge :username => 'willnotwork'
action = lambda { TinyTds::Client.new(options) }
Expand Down

0 comments on commit 7c256b3

Please sign in to comment.