fuel-library/deployment/puppet/osnailyfacter/spec/functions/nic_whitelist_to_mappings__spec.rb
Sergey Kolekonov 31b3acd084 Add unit tests for NFV-related functions
Add unit tests for the following functions:
- nic_whitelist_to_json
- nic_whitelist_to_mappings
- filter_nodes_with_enabled_option

Closes-bug: #1557974

Change-Id: Ia50c0e50d360b7557b19df3661ed980d8726c8c6
2016-03-19 13:01:03 +03:00

33 lines
963 B
Ruby

require 'spec_helper'
describe 'nic_whitelist_to_mappings' do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
let(:nic_whitelist) do
[{"devname"=>"eth1", "physical_network"=>"physnet2"}]
end
let(:physical_device_mappings) do
["physnet2:eth1"]
end
before(:each) do
puppet_debug_override()
end
it 'should exist' do
expect(Puppet::Parser::Functions.function('nic_whitelist_to_mappings')).to eq('function_nic_whitelist_to_mappings')
end
it 'should fail if more then one argument given' do
expect{scope.function_nic_whitelist_to_mappings([nic_whitelist, 'eee'])}.to raise_error(Puppet::ParseError, /one argument is allowed/)
end
it 'should return without arguments' do
expect(scope.function_nic_whitelist_to_mappings([])).to eq(nil)
end
it 'should convert nic whitelist to device mappings' do
expect(scope.function_nic_whitelist_to_mappings([nic_whitelist])).to eq(physical_device_mappings)
end
end