Skip to content

Commit 5771fc8

Browse files
authored
Merge pull request #26 from CU-CloudCollab/review-changes
changes to test per review with brett, fixed bug in restore waiter
2 parents d3384ed + 16daa21 commit 5771fc8

3 files changed

Lines changed: 43 additions & 12 deletions

File tree

lib/cucloud/rds_utils.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ def modify_security_group(db_instance_identifier, vpc_security_groups)
5656

5757
# Modify the options group for a RDS instance
5858
# @param db_instance_identifier [String] RDS instance identifier
59-
# @param option_group_name [Sting] Name od the options group to apply
59+
# @param option_group_name [Sting] Name of the options group to apply
6060
# @return [Hash] Hash represnting the return from AWS
6161
def modify_option_group(db_instance_identifier, option_group_name)
6262
modify_db_instance(db_instance_identifier: db_instance_identifier, option_group_name: option_group_name)
6363
end
6464

6565
# Base function to modify DB, resets defualts for apply_immediately and copy_tags_to_snapshot
66-
# @param options [hash] Hash represnting the configuration for the RDS restore
66+
# @param options [hash] Hash represnting the configuration for the RDS modify
6767
# @return [Hash] Hash represnting the return from AWS
6868
def modify_db_instance(options)
6969
options[:apply_immediately] = options[:apply_immediately].nil? ? true : options[:apply_immediately]
@@ -83,7 +83,7 @@ def restore_db(db_instance_identifier, restore_from, options = {})
8383
options[:db_instance_identifier] = db_instance_identifier
8484
options[:db_snapshot_identifier] = db_snapshot_identifier
8585
@rds.restore_db_instance_from_db_snapshot(options)
86-
@rds.wait_until(:db_instance_deleted, db_instance_identifier: db_instance_identifier)
86+
@rds.wait_until(:db_instance_available, db_instance_identifier: db_instance_identifier)
8787
end
8888

8989
# Delete a givne db instance

lib/cucloud/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Cucloud
22
# Disable mutable constant warning - freezing this oddly breaks bundler
33
# rubocop:disable Style/MutableConstant
4-
VERSION = '0.7.3'
4+
VERSION = '0.7.4'
55
end

spec/rds_utils_spec.rb

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,57 @@
6464
it 'shoud not rais an error' do
6565
expect { rds_utils.modify_security_group('testDb', ['sg-084646']) }.not_to raise_error
6666
end
67+
68+
it 'should get the correct default parameters' do
69+
expect(rds_client).to receive(:modify_db_instance).with(db_instance_identifier: 'testDb',
70+
vpc_security_group_ids: ['sg-084646'],
71+
apply_immediately: true,
72+
copy_tags_to_snapshot: true)
73+
rds_utils.modify_security_group('testDb', ['sg-084646'])
74+
end
6775
end
6876

6977
describe '#modify_option_group' do
7078
it 'shoud not rais an error' do
7179
expect { rds_utils.modify_option_group('testDb', 'options-group') }.not_to raise_error
7280
end
81+
82+
it 'should get the correct default parameters' do
83+
expect(rds_client).to receive(:modify_db_instance).with(db_instance_identifier: 'testDb',
84+
option_group_name: 'options-group',
85+
apply_immediately: true,
86+
copy_tags_to_snapshot: true)
87+
rds_utils.modify_option_group('testDb', 'options-group')
88+
end
89+
end
90+
91+
describe '#modify_db_instance' do
92+
it 'should allow your to override default values' do
93+
expect(rds_client).to receive(:modify_db_instance).with(db_instance_identifier: 'testDb',
94+
option_group_name: 'options-group',
95+
apply_immediately: false,
96+
copy_tags_to_snapshot: false)
97+
rds_utils.modify_db_instance(
98+
db_instance_identifier: 'testDb',
99+
option_group_name: 'options-group',
100+
apply_immediately: false,
101+
copy_tags_to_snapshot: false
102+
)
103+
end
73104
end
74105
end
75106

76107
context 'while describe_db_instances returns an instand not found error' do
77108
before do
78109
rds_client.stub_responses(
79110
:describe_db_instances,
80-
Aws::RDS::Errors::DBInstanceNotFound.new('test', 'test')
81-
)
82-
rds_client.stub_responses(
83-
:restore_db_instance_from_db_snapshot,
84-
db_instance: {
85-
db_instance_identifier: 'testDb'
86-
}
111+
[
112+
Aws::RDS::Errors::DBInstanceNotFound.new('test', 'test'),
113+
{ db_instances: [
114+
db_instance_identifier: 'testDb',
115+
db_instance_status: 'available'
116+
] }
117+
]
87118
)
88119
rds_client.stub_responses(
89120
:describe_db_snapshots,
@@ -116,7 +147,7 @@
116147
end
117148
end
118149

119-
context 'while describe_db_instances is returns an instand not found error' do
150+
context 'while describe_db_instances is mocked out' do
120151
before do
121152
rds_client.stub_responses(
122153
:delete_db_instance,

0 commit comments

Comments
 (0)