1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[simpleDB] - not populating the :replace attributes with keys from :expect.

This commit is contained in:
Jeremy Deininger 2010-06-22 20:03:41 -07:00 committed by geemus
parent 6ddf8e67a1
commit 53ce447574
2 changed files with 4 additions and 6 deletions

View file

@ -16,7 +16,7 @@ module Fog
# and sequences not allowed in xml are not valid. Each name and value can
# be up to 1024 bytes long.
# * options<~Hash> - Accepts the following keys.
# :replace => [Array of keys to replace, will be combined with any keys from :expect]
# :replace => [Array of keys to replace]
# :expect => {name/value pairs for performing conditional put}
#
# ==== Returns
@ -27,7 +27,6 @@ module Fog
def put_attributes(domain_name, item_name, attributes, options = {})
options[:expect] = {} unless options[:expect]
options[:replace] = [] unless options[:replace]
options[:replace] += options[:expect].keys
request({
'Action' => 'PutAttributes',
'DomainName' => domain_name,
@ -43,7 +42,6 @@ module Fog
def put_attributes(domain_name, item_name, attributes, options = {})
options[:expect] = {} unless options[:expect]
options[:replace] = [] unless options[:replace]
options[:replace] += options[:expect].keys
response = Excon::Response.new
if @data[:domains][domain_name]
options[:expect].each do |ck, cv|

View file

@ -20,8 +20,8 @@ describe 'SimpleDB.put_attributes' do
it 'conditional put should succeed' do
AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '1' })
AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' })
actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '3' }, :expect => { 'version' => '2' })
AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version'])
actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '3' }, :expect => { 'version' => '2' }, :replace => ['version'])
actual.body['RequestId'].should be_a(String)
actual.body['BoxUsage'].should be_a(Float)
end
@ -32,7 +32,7 @@ describe 'SimpleDB.put_attributes' do
actual.body['BoxUsage'].should be_a(Float)
lambda {
actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' })
actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version'])
}.should raise_error(Excon::Errors::Conflict)
end