iron_mq 3.1.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require 'test/unit'
2
2
  require 'beanstalk-client'
3
3
  require 'yaml'
4
- require 'test_base'
4
+ require File.expand_path('test_base.rb', File.dirname(__FILE__))
5
5
 
6
6
  class BeanstalkTests < TestBase
7
7
  def setup
@@ -103,6 +103,10 @@ class BeanstalkTests < TestBase
103
103
  job = reserve(1)
104
104
  assert_equal msg, job.body, "#{job.body} does not equal #{msg}"
105
105
  job.delete
106
+
107
+ # delete queue on test complete
108
+ resp = @client.queue('default').delete_queue
109
+ assert_equal 200, resp.code, "API must response with HTTP 200 status, but returned HTTP #{resp.code}"
106
110
  end
107
111
 
108
112
  def test_timeout
@@ -126,6 +130,10 @@ class BeanstalkTests < TestBase
126
130
  assert_not_nil job, "job is nil"
127
131
  assert_equal msg, job.body, "body not the same as message."
128
132
  job.delete
133
+
134
+ # delete queue on test complete
135
+ resp = @client.queue('default').delete_queue
136
+ assert_equal 200, resp.code, "API must response with HTTP 200 status, but returned HTTP #{resp.code}"
129
137
  end
130
138
 
131
139
  def test_delay
@@ -145,6 +153,10 @@ class BeanstalkTests < TestBase
145
153
  assert_not_nil job, "job is nil"
146
154
  assert_equal msg, job.body, "body not the same as message."
147
155
  job.delete
156
+
157
+ # delete queues on test complete
158
+ resp = @client.queue('default').delete_queue
159
+ assert_equal 200, resp.code, "API must response with HTTP 200 status, but returned HTTP #{resp.code}"
148
160
  end
149
161
 
150
162
  def tube_message(tube)
@@ -156,11 +168,11 @@ class BeanstalkTests < TestBase
156
168
  omit_if @skip # bypass this test if rackspace
157
169
  begin
158
170
  job = @beanstalk.reserve(timeout)
159
- puts 'got job: ' + job.inspect
160
- return job
171
+ LOG.info 'got job: ' + job.inspect
172
+ job
161
173
  rescue Beanstalk::TimedOut => ex
162
174
  puts "Timed out: #{ex.message}"
163
- return nil
175
+ nil
164
176
  end
165
177
  end
166
178
 
@@ -215,6 +227,16 @@ class BeanstalkTests < TestBase
215
227
  job = reserve(1)
216
228
  assert_equal msg1, job.body, "body #{job.body.to_s} does not equal #{msg1}"
217
229
  job.delete
230
+
231
+ # delete queues on test complete
232
+ resp = @client.queue('youtube').delete_queue
233
+ assert_equal 200, resp.code, "API must response with HTTP 200 status, but returned HTTP #{resp.code}"
234
+
235
+ resp = @client.queue('beanstalk_test').delete_queue
236
+ assert_equal 200, resp.code, "API must response with HTTP 200 status, but returned HTTP #{resp.code}"
237
+
238
+ resp = @client.queue('default').delete_queue
239
+ assert_equal 200, resp.code, "API must response with HTTP 200 status, but returned HTTP #{resp.code}"
218
240
  end
219
241
 
220
242
 
data/test/test_bulk.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'test_base'
1
+ require File.expand_path('test_base.rb', File.dirname(__FILE__))
2
2
 
3
3
  class TestBulk < TestBase
4
4
 
@@ -8,6 +8,7 @@ class TestBulk < TestBase
8
8
  end
9
9
 
10
10
  def test_bulk
11
+ LOG.info "test_bulk"
11
12
 
12
13
  q_name = 'ironmq-gem-bulk'
13
14
  queue = @client.queue(q_name)
@@ -18,15 +19,18 @@ class TestBulk < TestBase
18
19
  puts "Posting #{i}"
19
20
  res = queue.post("hello world #{i}!")
20
21
  end
21
- puts "#{times} posts took #{Time.now.to_f - t.to_f}"
22
+ LOG.info "#{times} posts took #{Time.now.to_f - t.to_f}"
22
23
 
23
24
  t = Time.now
24
25
  res = nil
25
26
  while (res = queue.get())
26
27
  del = res.delete
27
28
  end
28
- puts "#{times} gets and deletes took #{Time.now.to_f - t.to_f}"
29
+ LOG.info "#{times} gets and deletes took #{Time.now.to_f - t.to_f}"
29
30
 
31
+ # delete queue on test complete
32
+ resp = queue.delete_queue
33
+ assert_equal 200, resp.code, "API must response with HTTP 200 status, but returned HTTP #{resp.code}"
30
34
  end
31
35
 
32
36
  end