Skip to content

Commit

Permalink
[ec2] consolidate key pair tests
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed May 22, 2010
1 parent 785ce38 commit fb7555b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 102 deletions.
7 changes: 4 additions & 3 deletions lib/fog/aws/requests/ec2/delete_key_pair.rb
Expand Up @@ -15,9 +15,10 @@ class Real
# * 'return'<~Boolean> - success?
def delete_key_pair(key_name)
request(
'Action' => 'DeleteKeyPair',
'KeyName' => key_name,
:parser => Fog::Parsers::AWS::EC2::Basic.new
'Action' => 'DeleteKeyPair',
'KeyName' => key_name,
:idempotent => true,
:parser => Fog::Parsers::AWS::EC2::Basic.new
)
end

Expand Down
36 changes: 0 additions & 36 deletions spec/aws/requests/ec2/create_key_pair_spec.rb

This file was deleted.

21 changes: 0 additions & 21 deletions spec/aws/requests/ec2/delete_key_pair_spec.rb

This file was deleted.

42 changes: 0 additions & 42 deletions spec/aws/requests/ec2/describe_key_pairs_spec.rb

This file was deleted.

44 changes: 44 additions & 0 deletions tests/aws/requests/ec2/key_pair_tests.rb
@@ -0,0 +1,44 @@
Shindo.tests('AWS::EC2 | key pair requests', ['aws']) do

tests('success') do

@key_pair_name = 'fog_key_pair'

tests("#create_key_pair('#{@key_pair_name}')").formats({ 'keyFingerprint' => String, 'keyMaterial' => String, 'keyName' => String, 'requestId' => String }) do
AWS[:ec2].create_key_pair(@key_pair_name).body
end

tests('#describe_key_pairs').formats({ 'keySet' => [{'keyFingerprint' => String, 'keyName' => String}], 'requestId' => String }) do
AWS[:ec2].describe_key_pairs.body
end

tests("#describe_key_pairs(#{@key_pair_name})").formats({ 'keySet' => [{'keyFingerprint' => String, 'keyName' => String}], 'requestId' => String }) do
AWS[:ec2].describe_key_pairs(@key_pair_name).body
end

tests("#delete_key_pair('#{@key_pair_name}')").formats(AWS::EC2::Formats::BASIC) do
AWS[:ec2].delete_key_pair(@key_pair_name).body
end

tests("#delete_key_pair('not_a_key_name')").succeeds do
AWS[:ec2].delete_key_pair('not_a_key_name')
end

end
tests('failure') do

@key_pair = AWS[:ec2].key_pairs.create(:name => 'fog_key_pair')

tests("duplicate #create_key_pair('#{@key_pair.name}')").raises(Excon::Errors::BadRequest) do
AWS[:ec2].create_key_pair(@key_pair.name)
end

tests("#describe_key_pair('not_a_key_name')").raises(Excon::Errors::BadRequest) do
AWS[:ec2].describe_key_pairs('not_a_key_name').body
end

@key_pair.destroy

end

end

0 comments on commit fb7555b

Please sign in to comment.