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

[hp|storage] Minor fixes to directory metadata and along with tests for metadata.

This commit is contained in:
Rupak Ganguly 2013-07-01 16:21:32 -04:00
parent f03ee19575
commit 0eee5d8ee6
3 changed files with 75 additions and 1 deletions

View file

@ -261,7 +261,9 @@ module Fog
# get the metadata and merge them in
meta_hash = {}
metadata.each { |meta| meta_hash.store(meta.key, meta.value) }
options.merge!(meta_hash)
if meta_hash
options.merge!(meta_hash)
end
service.put_container(key, options)
# Added an extra check to see if CDN is enabled for the container
if (!service.cdn.nil? && service.cdn.enabled?)

View file

@ -20,6 +20,8 @@ module Fog
metadata.each_pair {|k,v| metas << {'key' => k, 'value' => v} }
load(metas)
end
rescue Fog::Storage::HP::NotFound
nil
end
def destroy

View file

@ -43,6 +43,75 @@ Shindo.tests("Fog::Storage[:hp] | directory", ['hp', 'storage']) do
@instance.cdn_public_ssl_url
end
# metadata tests
tests('#metadata.all').succeeds do
@instance.metadata.all
end
tests('#metadata.set').succeeds do
@instance.metadata.set('X-Container-Meta-One' => 'One')
end
tests('#metadata.get set meta').succeeds do
meta = @instance.metadata.get('X-Container-Meta-One')
tests('gets correct value') do
meta.value == 'One'
end
meta
end
tests('#metadata.update').succeeds do
@instance.metadata.update('X-Container-Meta-One' => 'One Updated')
end
tests('#metadata.get updated meta').succeeds do
meta = @instance.metadata.get('X-Container-Meta-One')
tests('gets correct value') do
meta.value == 'One Updated'
end
meta
end
# metadata set via setter
tests('#metadata=').succeeds do
@instance.metadata = {'X-Container-Meta-Two' => 'Two'}
@instance.save
end
tests('#metadata.get set meta via setter').succeeds do
meta = @instance.metadata.get('X-Container-Meta-Two')
tests('gets correct value') do
meta.value == 'Two'
end
meta
end
#metadata set via Meta object
tests('metadata set via Meta object').succeeds do
m = Fog::Storage::HP::Meta.new
m.key = 'X-Container-Meta-Three'
m.value = 'Three'
@instance.metadata << m
@instance.save
end
tests('#metadata.get set via Meta object').succeeds do
meta = @instance.metadata.get('X-Container-Meta-Three')
tests('gets correct value') do
meta.value == 'Three'
end
meta
end
# invalid metadata
tests("#metadata.get('invalid-meta')").succeeds do
meta = @instance.metadata.get('X-Container-Meta-InValidMeta')
tests('gets nil') do
meta == nil
end
meta
end
end
tests('failure') do
@ -55,6 +124,7 @@ Shindo.tests("Fog::Storage[:hp] | directory", ['hp', 'storage']) do
@instance.revoke('invalid-acl')
end
end
end