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

Merge pull request #2288 from alphagov/improved_tests_for_ensure_list

[vcloud_director] improved tests for #ensure_list!
This commit is contained in:
Nick Osborn 2013-10-21 10:18:49 -07:00
commit 08d3b2ff41

View file

@ -5,7 +5,7 @@ Shindo.tests('Compute::VcloudDirector | ensure_list!', ['vclouddirector']) do
@service = Fog::Compute::VcloudDirector.new
tests('#ensure_list! for single key') do
tests('#ensure_list! for single key ensures our key has an array as a value') do
tests('for key with a hash').returns(Array) do
testdata = {:k => {:A => '1'}}
@service.ensure_list!(testdata, :k)
@ -31,7 +31,7 @@ Shindo.tests('Compute::VcloudDirector | ensure_list!', ['vclouddirector']) do
end
end
tests ('#ensure_list! for nested keys') do
tests('#ensure_list! for nested keys ensures that the child key has an array as a value') do
tests('with no key').returns(Array) do
testdata = {}
@service.ensure_list!(testdata, :keys, :key)
@ -51,6 +51,34 @@ Shindo.tests('Compute::VcloudDirector | ensure_list!', ['vclouddirector']) do
end
end
tests('#ensure_list! with parent and child keys does not effect existing data') do
tests('for existing array').returns([:one, :two]) do
testdata = {:keys => {:key => [:one, :two]}}
@service.ensure_list!(testdata, :keys, :key)
testdata[:keys][:key]
end
tests('for existing hash').returns([{:one => :two}]) do
testdata = {:keys => {:key => {:one => :two}}}
@service.ensure_list!(testdata, :keys, :key)
testdata[:keys][:key]
end
end
tests('#ensure_list! with single key does not effect existing data') do
tests('for existing array').returns([:one, :two]) do
testdata = {:k => [:one, :two]}
@service.ensure_list!(testdata, :k)
testdata[:k]
end
tests('for existing hash').returns([{:one => 'two'}]) do
testdata = {:k => {:one => 'two'}}
@service.ensure_list!(testdata, :k)
testdata[:k]
end
end
end
end