From d5fd93cc5c781c3531551a54c8675cfe87390be4 Mon Sep 17 00:00:00 2001 From: Eugene Howe Date: Tue, 24 Mar 2015 14:06:22 -0400 Subject: [PATCH] mock DescribeDBEngineVersions --- lib/fog/aws/rds.rb | 16 ++++++++++++++++ .../requests/rds/describe_db_engine_versions.rb | 9 ++++++++- tests/requests/rds/db_engine_versions.rb | 7 +++++++ tests/requests/rds/helper.rb | 14 ++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/requests/rds/db_engine_versions.rb diff --git a/lib/fog/aws/rds.rb b/lib/fog/aws/rds.rb index 1b33eed06..4a3abeda8 100644 --- a/lib/fog/aws/rds.rb +++ b/lib/fog/aws/rds.rb @@ -101,6 +101,22 @@ module Fog :subnet_groups => {}, :snapshots => {}, :event_subscriptions => {}, + :db_engine_versions => [ + { + 'Engine' => "mysql", + 'DBParameterGroupFamily' => "mysql5.1", + 'DBEngineDescription' => "MySQL Community Edition", + 'EngineVersion' => "5.1.57", + 'DBEngineVersionDescription' => "MySQL 5.1.57" + }, + { + 'Engine' => "postgres", + 'DBParameterGroupFamily' => "postgres9.3", + 'DBEngineDescription' => "PostgreSQL", + 'EngineVersion' => "9.3.5", + 'DBEngineVersionDescription' => "PostgreSQL 9.3.5" + }, + ], :parameter_groups => { "default.mysql5.1" => { "DBParameterGroupFamily" => "mysql5.1", diff --git a/lib/fog/aws/requests/rds/describe_db_engine_versions.rb b/lib/fog/aws/requests/rds/describe_db_engine_versions.rb index 491c0e07f..b0fbbb2a6 100644 --- a/lib/fog/aws/requests/rds/describe_db_engine_versions.rb +++ b/lib/fog/aws/requests/rds/describe_db_engine_versions.rb @@ -22,7 +22,14 @@ module Fog class Mock def describe_db_engine_versions(opts={}) - Fog::Mock.not_implemented + response = Excon::Response.new + + response.status = 200 + response.body = { + "ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id }, + "DescribeDBEngineVersionsResult" => { "DBEngineVersions" => self.data[:db_engine_versions] } + } + response end end end diff --git a/tests/requests/rds/db_engine_versions.rb b/tests/requests/rds/db_engine_versions.rb new file mode 100644 index 000000000..2c93b6aa2 --- /dev/null +++ b/tests/requests/rds/db_engine_versions.rb @@ -0,0 +1,7 @@ +Shindo.tests('AWS::RDS | describe db engine versions', ['aws', 'rds']) do + tests('success') do + tests("#describe_db_engine_versions").formats(AWS::RDS::Formats::DB_ENGINE_VERSIONS_LIST) do + Fog::AWS[:rds].describe_db_engine_versions.body + end + end +end diff --git a/tests/requests/rds/helper.rb b/tests/requests/rds/helper.rb index df28475d3..6ac5dec53 100644 --- a/tests/requests/rds/helper.rb +++ b/tests/requests/rds/helper.rb @@ -291,6 +291,20 @@ class AWS 'EventSubscriptionsList' => [EVENT_SUBSCRIPTION] } } + + DB_ENGINE_VERSION = { + 'Engine' => String, + 'DBParameterGroupFamily' => String, + 'DBEngineDescription' => String, + 'EngineVersion' => String, + 'DBEngineVersionDescription' => String + } + + DB_ENGINE_VERSIONS_LIST = BASIC.merge( + 'DescribeDBEngineVersionsResult' => { + 'DBEngineVersions' => [DB_ENGINE_VERSION] + } + ) end end end