-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #547 from glasswalk3r/feature/missing_sns_specs
Added missing SNS specs
- Loading branch information
Showing
4 changed files
with
68 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
OWNER = '123456789' | ||
REGION = 'us-east-1' | ||
TOPIC_ARN = "arn:aws:sns:#{REGION}:#{OWNER}:invalid" | ||
TOPIC_SUBS_ARN = "arn:aws:sns:us-east-1:#{OWNER}:Foobar:3dbf4999-b3e2-4345-bd11-c34c9784ecca" | ||
|
||
Aws.config[:sns] = { | ||
stub_responses: { | ||
get_topic_attributes: Aws::SNS::Errors::NotFound.new( | ||
TOPIC_ARN, 'no such topic'), | ||
list_subscriptions_by_topic: Aws::SNS::Errors::NotFound.new( | ||
TOPIC_SUBS_ARN, 'no such topic') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'spec_helper' | ||
Awspec::Stub.load 'sns_topic_error' | ||
|
||
describe sns_topic(TOPIC_ARN) do | ||
it { should_not exist } | ||
its(:name) { will raise_error(Awspec::NoExistingResource) } | ||
its(:confirmed_subscriptions) { will raise_error(Awspec::NoExistingResource) } | ||
its(:pending_subscriptions) { will raise_error(Awspec::NoExistingResource) } | ||
its(:topic_arn) { will raise_error(Awspec::NoExistingResource) } | ||
its(:display_name) { will raise_error(Awspec::NoExistingResource) } | ||
its(:deleted_subscriptions) { will raise_error(Awspec::NoExistingResource) } | ||
its(:subscriptions) { will raise_error(Awspec::NoExistingResource) } | ||
its(:id) { will_not raise_error } | ||
its(:id) { should be_nil } | ||
|
||
it 'include_subscribed matcher raises Awspec::NoExistingResource' do | ||
expect { should include_subscribed(TOPIC_SUBS_ARN) }.to raise_error(Awspec::NoExistingResource) | ||
end | ||
|
||
let(:expected_attribs) do | ||
{ protocol: 'lambda', | ||
owner: OWNER, | ||
subscription_arn: TOPIC_SUBS_ARN, # this is required | ||
endpoint: "arn:aws:lambda:#{REGION}:#{OWNER}:function:foobar" } | ||
end | ||
|
||
it 'have_subscription_attributes matcher raises Awspec::NoExistingResource' do | ||
expect { should have_subscription_attributes(expected_attribs) }.to raise_error(Awspec::NoExistingResource) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,24 @@ | ||
require 'spec_helper' | ||
Awspec::Stub.load 'sns_topic' | ||
|
||
# based on values from lib/awspec/sub/sns_topic.rb | ||
topic_arn = 'arn:aws:sns:us-east-1:123456789:foobar' | ||
subscribed = 'arn:aws:sns:us-east-1:123456789:Foobar:3dbf4999-b3e2-4345-bd11-c34c9784ecca' | ||
|
||
describe sns_topic(topic_arn) do | ||
describe sns_topic(TOPIC_ARN) do | ||
it { should exist } | ||
its(:name) { should eq 'foobar' } | ||
its(:confirmed_subscriptions) { should eq 1 } | ||
its(:pending_subscriptions) { should eq 0 } | ||
its(:topic_arn) { should eq topic_arn } | ||
its(:display_name) { should eq 'Useless' } | ||
its(:topic_arn) { should eq TOPIC_ARN } | ||
its(:display_name) { should eq DISPLAY_NAME } | ||
its(:deleted_subscriptions) { should eq 0 } | ||
its(:subscriptions) { should eql([:"arn:aws:sns:us-east-1:123456789:Foobar:3dbf4999-b3e2-4345-bd11-c34c9784ecca"]) } | ||
its(:id) { should eq 'arn:aws:sns:us-east-1:123456789:foobar' } | ||
its(:subscriptions) { should eql([SUBSCRIBED.to_sym]) } | ||
its(:id) { should eq TOPIC_ARN } | ||
|
||
let(:expected_attribs) do | ||
{ protocol: 'lambda', | ||
owner: '123456789', | ||
subscription_arn: subscribed, # this is required | ||
endpoint: 'arn:aws:lambda:us-east-1:123456789:function:foobar' } | ||
end | ||
|
||
describe '#include_subscribed' do | ||
it { should include_subscribed(subscribed) } | ||
end | ||
|
||
describe '#subscribed' do | ||
it do | ||
should have_subscription_attributes(expected_attribs) | ||
end | ||
owner: OWNER, | ||
subscription_arn: SUBSCRIBED, # this is required | ||
endpoint: ENDPOINT } | ||
end | ||
end | ||
|
||
invalid_topic_arn = 'arn:aws:sns:us-east-1:123456789:invalid' | ||
|
||
describe sns_topic(invalid_topic_arn) do | ||
context 'Issue https://github.com/k1LoW/awspec/issues/445 is still open' do | ||
it 'it does not exists' | ||
it ':name raises Awspec::NoExistingResource' | ||
it ':confirmed_subscriptions raises Awspec::NoExistingResource' | ||
it ':pending_subscriptions raises Awspec::NoExistingResource' | ||
it ':topic_arn raises Awspec::NoExistingResource' | ||
it ':display_name raises Awspec::NoExistingResource' | ||
it ':deleted_subscriptions raises Awspec::NoExistingResource' | ||
it ':subscriptions raises Awspec::NoExistingResource' | ||
it ':id raises Awspec::NoExistingResource' | ||
it 'matcher include_subscribed raises Awspec::NoExistingResource' | ||
it 'matcher have_subscription_attributes raises Awspec::NoExistingResource' | ||
end | ||
it { should include_subscribed(SUBSCRIBED) } | ||
it { should have_subscription_attributes(expected_attribs) } | ||
end |