test/components/queue_subscription_test.rb in propono-0.9.1 vs test/components/queue_subscription_test.rb in propono-0.10.0
- old
+ new
@@ -1,13 +1,24 @@
require File.expand_path('../../test_helper', __FILE__)
module Propono
class QueueSubscriptionTest < Minitest::Test
+ def setup
+ super
+ @suffix = "-suf"
+ Propono.config.queue_suffix = @suffix
+ end
+
+ def teardown
+ super
+ Propono.config.queue_suffix = ""
+ end
+
def test_create_topic
topic_id = 'foobar'
topic = Topic.new(topic_id)
- TopicCreator.expects(:find_or_create).with(topic_id).returns(topic)
+ TopicCreator.expects(:find_or_create).with("#{topic_id}#{@suffix}").returns(topic)
QueueSubscription.create(topic_id)
end
def test_sqs_create_is_called
topic_id = "Foobar"
@@ -26,20 +37,20 @@
Propono.config.application_name = "MyApp"
topic_id = "Foobar"
subscription = QueueSubscription.new(topic_id)
- assert_equal subscription.send(:queue_name), "MyApp-Foobar"
+ assert_equal "MyApp-Foobar#{@suffix}", subscription.send(:queue_name)
end
def test_subscription_queue_name_with_spaces
Propono.config.application_name = "My App"
topic_id = "Foobar"
subscription = QueueSubscription.new(topic_id)
- assert_equal subscription.send(:queue_name), "My_App-Foobar"
+ assert_equal "My_App-Foobar#{@suffix}", subscription.send(:queue_name)
end
def test_create_calls_subscribe
arn = "arn123"
@@ -75,10 +86,17 @@
subscription = QueueSubscription.new("Some Topic")
subscription.create
assert_equal queue, subscription.queue
end
+ def test_create_raises_with_nil_topic
+ subscription = QueueSubscription.new(nil)
+ assert_raises ProponoError do
+ subscription.create
+ end
+ end
+
def test_generate_policy
- skip"TODO - Implement this test."
+ skip "TODO - Implement this test."
end
end
end