Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
tests for commenting of esns email subscription tf
Browse files Browse the repository at this point in the history
  • Loading branch information
uberblah committed Jun 2, 2017
1 parent 30facaf commit 23e1a32
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions spec/lib/terraforming/resource/sns_topic_subscription_spec.rb
Expand Up @@ -14,7 +14,7 @@ module Resource
]
end

let(:attributes) do
let(:attributes_regular) do
{
"Endpoint" => "arn:aws:sqs:us-west-2:012345678901:a-cool-queue",
"Protocol" => "sqs",
Expand All @@ -26,13 +26,25 @@ module Resource
}
end

let(:attributes_email) do
{
"Endpoint" => "arn:aws:sqs:us-west-2:012345678901:a-cool-queue",
"Protocol" => "email-json",
"RawMessageDelivery" => "false",
"ConfirmationWasAuthenticated" => "true",
"Owner" => "012345678901",
"SubscriptionArn" => "arn:aws:sns:us-west-2:012345678901:a-cool-topic:000ff1ce-dead-beef-f00d-ea7food5a1d1",
"TopicArn" => "arn:aws:sns:us-west-2:012345678901:a-cool-topic"
}
end

before do
client.stub_responses(:list_subscriptions, subscriptions: subscriptions)
client.stub_responses(:get_subscription_attributes, attributes: attributes)
client.stub_responses(:get_subscription_attributes, attributes: attributes_regular)
end

describe ".tf" do
it "should generate tf" do
it "should generate tf for non-email subscriptions" do
expect(described_class.tf(client: client)).to eq <<-EOS
resource "aws_sns_topic_subscription" "000ff1ce-dead-beef-f00d-ea7food5a1d1" {
topic_arn = "arn:aws:sns:us-west-2:012345678901:a-cool-topic"
Expand All @@ -41,6 +53,20 @@ module Resource
raw_message_delivery = "false"
}

EOS
end
it "should generate commented tf for email subscriptions" do
client.stub_responses(:get_subscription_attributes, attributes: attributes_email)
expect(described_class.tf(client: client)).to eq <<-EOS
/*
resource "aws_sns_topic_subscription" "000ff1ce-dead-beef-f00d-ea7food5a1d1" {
topic_arn = "arn:aws:sns:us-west-2:012345678901:a-cool-topic"
protocol = "email-json"
endpoint = "arn:aws:sqs:us-west-2:012345678901:a-cool-queue"
raw_message_delivery = "false"
}
*/

EOS
end
end
Expand Down

0 comments on commit 23e1a32

Please sign in to comment.