Permalink
Browse files

Added super token

  • Loading branch information...
1 parent 9ba87bc commit 6f553e3aef2007088f17a3e8187992ecda3609e6 @treeder treeder committed Apr 23, 2013
Showing with 58 additions and 0 deletions.
  1. +6 −0 Gemfile.lock
  2. +1 −0 iron_mq.gemspec
  3. +51 −0 test/test_mq_worker_subscribers.rb
View
@@ -15,6 +15,10 @@ GEM
ffi (1.7.0)
iron_core (0.6.0)
rest (>= 2.2.0)
+ iron_worker_ng (0.16.4)
+ bundler (>= 1.2.0)
+ iron_core (>= 0.5.1)
+ rubyzip (>= 0.9.9)
mime-types (1.22)
minitest (4.7.1)
net-http-persistent (2.8)
@@ -24,6 +28,7 @@ GEM
rest-client (>= 0.3.0)
rest-client (1.6.7)
mime-types (>= 1.16)
+ rubyzip (0.9.9)
test-unit (2.5.4)
typhoeus (0.6.3)
ethon (~> 0.5.11)
@@ -36,6 +41,7 @@ DEPENDENCIES
beanstalk-client
concur
iron_mq!
+ iron_worker_ng
minitest
net-http-persistent
quicky
View
@@ -27,6 +27,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "concur"
gem.add_development_dependency "net-http-persistent"
gem.add_development_dependency "quicky"
+ gem.add_development_dependency "iron_worker_ng"
end
@@ -0,0 +1,51 @@
+# Put config.yml file in ~/Dropbox/configs/ironmq_gem/test/config.yml
+require File.expand_path('test_base.rb', File.dirname(__FILE__))
+require 'logger'
+
+class TestPushQueues < TestBase
+
+ def setup
+ super
+ end
+
+ def make_key(i, t, random=0)
+ key = "pushq-#{t}-#{i}-#{random}"
+ end
+
+
+ def test_mq_worker_subscribers
+
+ qname = "push_receiver"
+ code_name = "hello"
+ queue = @client.queue(qname)
+ subscribers = []
+ subscribers << {:url => "ironmq:///#{qname}"}
+ subscribers << {:url => "ironworker:///#{code_name}"}
+ # requires a hello worker in your project, run next line to add one:
+ # > iron_worker upload https://github.com/treeder/hello_worker/blob/master/hello.worker
+
+ res = queue.update_queue(:subscribers => subscribers)
+
+ LOG.debug queue.subscribers
+ assert_equal subscribers.size, queue.subscribers.size
+
+ body = "Hello IronMQ pusher!"
+ m = queue.post(body)
+
+ sleep 2
+ # now check that there's a message in the queue and that the worker got a job
+ receiver_queue = @client.queue(qname)
+ assert_equal 1, receiver_queue.size
+ m2 = receiver_queue.get
+ assert_equal m.id, m2.id
+ assert_equal body, m2.body
+ m2.delete
+
+ iron_worker = IronWorkerNG::Client.new(@client.options)
+ tasks = iron_worker.tasks.list(:code_name=>code_name, :from_time=>Time.now - 30)
+ assert_equal 1, tasks.size
+
+
+ end
+
+end

0 comments on commit 6f553e3

Please sign in to comment.