test/integration/udp_proxy_test.rb in propono-0.8.2 vs test/integration/udp_proxy_test.rb in propono-0.9.0

- old
+ new

@@ -2,29 +2,39 @@ module Propono class UdpProxyTest < IntegrationTest def test_the_message_gets_there topic = "test-topic" - message = "This is my message" + text = "This is my message" + flunks = [] + Propono.config.udp_port = 20001 Propono.subscribe_by_queue(topic) sqs_thread = Thread.new do - Propono.listen_to_queue(topic) do |sqs_message| - assert_equal message, sqs_message + begin + Propono.listen_to_queue(topic) do |message, context| + flunks << "Wrong message" unless text == message + flunks << "Wrong id" unless context[:id] =~ Regexp.new("[a-z0-9]{6}-[a-z0-9]{6}") + break + end + rescue => e + flunks << e.message + ensure sqs_thread.terminate end end udp_thread = Thread.new do Propono.proxy_udp end sleep(2) # Make sure the proxy has started - Propono.publish(topic, message, protocol: :udp) - flunk("Test timeout") unless wait_for_thread(sqs_thread) + Propono::Publisher.publish(topic, text, protocol: :udp) + flunks << "Test timeout" unless wait_for_thread(sqs_thread) + flunk(flunks.join("\n")) unless flunks.empty? ensure udp_thread.terminate sqs_thread.terminate end end