56f55f373a
Fix broken tests Change-Id: Icee2c6aaf861063fcbccaff4fddbecf377a0695f Partial-bug: #1490578 Co-authored-by: Dmitry Ilyin <dilyin@mirantis.com>
56 lines
1.1 KiB
Ruby
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
|