Skip to content
This repository has been archived by the owner on Jan 20, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Added create_db_parameter_group and tests
  • Loading branch information
auser committed Oct 28, 2009
1 parent 2d42e7e commit df9a5ab
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
20 changes: 20 additions & 0 deletions lib/AWS/RDS/rds.rb
Expand Up @@ -66,6 +66,26 @@ def delete_db_instance( options = {} )

return response_generator(:action => "DeleteDBInstance", :params => params)
end

# This API method creates a db parameter group
#
# @option options [String] :db_parameter_group_name is the name of the parameter group (nil)
# @option options [String] :engine is the engine the db parameter group can be used with (nil)
# @option options [String] :description is the description of the paramter group
#
def create_db_parameter_group( options = {} )
raise ArgumentError, "No :db_parameter_group_name provided" if options.does_not_have?(:db_parameter_group_name)
raise ArgumentError, "No :engine provided" if options.does_not_have?(:engine)
raise ArgumentError, "No :description provided" if options.does_not_have?(:description)

params = {}
params['DBParameterGroupName'] = options[:db_parameter_group_name]
params['Engine'] = options[:engine]
params['Description'] = options[:description]

return response_generator(:action => "CreateDBParameterGroup", :params => params)
end


# This API method creates a db security group
#
Expand Down
32 changes: 31 additions & 1 deletion test/test_RDS.rb
Expand Up @@ -48,7 +48,7 @@
RESPONSE
end

specify "should be able to be create a db_isntance" do
specify "should be able to be create a db_instance" do
@rds.stubs(:make_request).with('CreateDBInstance', {'Engine' => 'MySQL5.1',
'MasterUsername' => 'master',
'DBInstanceClass' => 'db.m1.large',
Expand Down Expand Up @@ -83,4 +83,34 @@
assert_equal response.CreateDBSecurityGroupResult.DBSecurityGroup.DBSecurityGroupName, "mydbsecuritygroup4"
end

specify "should be able to create_db_parameter_group" do
body =<<-EOE
<CreateDBParameterGroupResponse xmlns="http://rds.amazonaws.com/admin/2009-10-16/">
<CreateDBParameterGroupResult>
<DBParameterGroup>
<Engine>mysql5.1</Engine>
<Description>My new DBParameterGroup</Description>
<DBParameterGroupName>mydbparametergroup3</DBParameterGroupName>
</DBParameterGroup>
</CreateDBParameterGroupResult>
<ResponseMetadata>
<RequestId>0b447b66-bf36-11de-a88b-7b5b3d23b3a7</RequestId>
</ResponseMetadata>
</CreateDBParameterGroupResponse>
EOE
@rds.stubs(:make_request).with('CreateDBParameterGroup', {'Engine' => 'MySQL5.1',
'DBParameterGroupName' => 'mydbsecuritygroup',
'Description' => 'My test DBSecurity group'}).
returns stub(:body => body, :is_a? => true)
response = @rds.create_db_parameter_group(
:db_parameter_group_name => "mydbsecuritygroup",
:description => "My test DBSecurity group",
:engine => "MySQL5.1"
)
response.should.be.an.instance_of Hash

assert_equal response.CreateDBParameterGroupResult.DBParameterGroup.DBParameterGroupName, "mydbparametergroup3"
end


end

0 comments on commit df9a5ab

Please sign in to comment.