Permalink
Browse files

Make sure the API returns the correct timeout numbers

  • Loading branch information...
1 parent ee30f77 commit 0ae821bb3a8e5d8f820f07f79dfc7a233c0aa847 @edsrzf edsrzf committed Feb 8, 2013
Showing with 25 additions and 1 deletion.
  1. +25 −1 test/test_iron_mq.rb
View
@@ -156,11 +156,12 @@ def test_timeout
assert_not_equal tries, 0
# now try explicit timeout
- res = @client.messages.post("hello world timeout2!", :timeout => 5)
+ res = @client.messages.post("hello world timeout2!", :timeout => 30)
p res
msg = @client.messages.get()
p msg
assert msg
+ assert_equal msg.raw['timeout'], 30
msg_nil = @client.messages.get()
p msg_nil
assert_nil msg_nil
@@ -173,6 +174,29 @@ def test_timeout
new_msg = @client.messages.get()
next if new_msg.nil?
assert_equal new_msg.id, msg.id
+ new_msg.delete
+ break
+ end
+ assert_not_equal tries, 0
+
+ # timeout on get
+ res = @client.messages.post("hello world timeout3!")
+ msg = @client.messages.get(:timeout => 30)
+ assert msg
+ assert_equal msg.raw['timeout'], 30
+ msg_nil = @client.messages.get()
+ p msg_nil
+ assert_nil msg_nil
+
+ tries = MAX_TRIES
+ while tries > 0
+ sleep 0.5
+ tries -= 1
+ sleep 1
+ new_msg = @client.messages.get()
+ next if new_msg.nil?
+ assert_equal new_msg.id, msg.id
+ new_msg.delete
break
end
assert_not_equal tries, 0

0 comments on commit 0ae821b

Please sign in to comment.