fuel-library/deployment/puppet/osnailyfacter/spec/functions/nodes_with_roles__spec.rb
Stanislav Makar 56f55f373a Enable rspec unit tests for osnailyfacter module
Fix broken tests

Change-Id: Icee2c6aaf861063fcbccaff4fddbecf377a0695f
Partial-bug: #1490578
Co-authored-by: Dmitry Ilyin <dilyin@mirantis.com>
2015-10-20 12:42:51 +00:00

56 lines
1.1 KiB
Ruby

require 'spec_helper'
describe 'nodes_with_roles' do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
it 'should exist' do
Puppet::Parser::Functions.function('nodes_with_roles').should == 'function_nodes_with_roles'
end
it 'should return array of matching nodes' do
nodes = [
{
'uid' => 1,
'role' => 'role1',
},
{
'uid' => 2,
'role' => 'role2',
},
{
'uid' => 3,
'role' => 'role3',
}
]
scope.function_nodes_with_roles([ nodes, ['role1', 'role2'] ]).should == [
{
'uid' => 1,
'role' => 'role1',
},
{
'uid' => 2,
'role' => 'role2',
}
]
end
it 'should eliminate duplicate uids' do
nodes = [
{
'uid' => 1,
'role' => 'role1',
},
{
'uid' => 1,
'role' => 'role2',
},
{
'uid' => 2,
'role' => 'role3',
}
]
scope.function_nodes_with_roles([ nodes, ['role1', 'role2'], 'uid' ]).should == [1]
end
end