Fix unmatched integration noop tests for vmware

Partial fix vmware compute cases:
* fix create_resources wrong reference
* fix the parse_vcenter_settings to work with ruby 2
* disable non passing cases (TODO for the integration team to fix them)

Partial-bug: #1563215

Change-Id: Ib201095118de34d272bb12c0af1c4e0f7596fa17
Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
This commit is contained in:
Bogdan Dobrelya
2016-03-29 11:31:12 +02:00
parent 99f4909ad8
commit 992bcd1432
4 changed files with 81 additions and 33 deletions

View File

@@ -1,16 +1,19 @@
# Eventually this functions should be revised and removed.
# Such data structure forming should be done by nailgun
Puppet::Parser::Functions::newfunction(
:parse_vcenter_settings,
:type => :rvalue,
:doc => <<-EOS
:parse_vcenter_settings,
:type => :rvalue,
:arity => 1,
:doc => <<-EOS
Convert array of computes of vCenter settings to hash
EOS
) do |args|
unless args.size > 0
raise Puppet::ParseError, "You should give an array of computes!"
end
settings = args[0]
settings_hash = Hash[(0...settings.size).zip settings]
settings = [settings] unless settings.is_a? Array
settings_hash = {}
settings.each_with_index do |value, key|
next unless value.is_a? Hash
settings_hash.store key.to_s, value
end
settings_hash
end

View File

@@ -0,0 +1,43 @@
require 'spec_helper'
describe 'parse_vcenter_settings', :type => :puppet_function do
it { is_expected.to run.with_params().and_raise_error(ArgumentError) }
it { is_expected.to run.with_params([]).and_return({}) }
it { is_expected.to run.with_params('').and_return({}) }
it { is_expected.to run.with_params(1).and_return({}) }
it { is_expected.to run.with_params(nil).and_return({}) }
it { is_expected.to run.with_params(
{
'a' => '1',
}
).and_return(
{
'0' => {
'a' => '1',
}
}
) }
it { is_expected.to run.with_params(
[
{
'a' => '1',
},
{
'a' => '2',
'b' => '3',
},
]
).and_return(
{
'0' => {
'a' => '1',
},
'1' => {
'a' => '2',
'b' => '3',
}
}
) }
end