2014-05-07 03:48:59 +02:00
|
|
|
#! /usr/bin/env ruby -S rspec
|
|
|
|
require 'spec_helper_acceptance'
|
|
|
|
|
|
|
|
describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
|
|
|
describe 'success' do
|
|
|
|
let(:facts_d) do
|
2014-06-24 20:37:34 +02:00
|
|
|
if fact('is_pe', '--puppet') == "true"
|
2014-06-24 08:27:59 +02:00
|
|
|
if fact('osfamily') =~ /windows/i
|
|
|
|
if fact('kernelmajversion').to_f < 6.0
|
2014-06-25 00:03:58 +02:00
|
|
|
'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
|
2014-06-24 08:27:59 +02:00
|
|
|
else
|
2014-06-25 00:03:58 +02:00
|
|
|
'C:/ProgramData/PuppetLabs/facter/facts.d'
|
2014-06-24 08:27:59 +02:00
|
|
|
end
|
|
|
|
else
|
|
|
|
'/etc/puppetlabs/facter/facts.d'
|
|
|
|
end
|
2014-05-07 03:48:59 +02:00
|
|
|
else
|
|
|
|
'/etc/facter/facts.d'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
after :each do
|
|
|
|
shell("if [ -f #{facts_d}/fqdn.txt ] ; then rm #{facts_d}/fqdn.txt ; fi")
|
|
|
|
end
|
2014-06-24 08:27:59 +02:00
|
|
|
before :all do
|
|
|
|
#No need to create on windows, PE creates by default
|
|
|
|
if fact('osfamily') !~ /windows/i
|
|
|
|
shell("mkdir -p #{facts_d}")
|
|
|
|
end
|
|
|
|
end
|
2014-05-07 03:48:59 +02:00
|
|
|
it 'fqdn_rotates floats' do
|
2014-06-25 19:16:06 +02:00
|
|
|
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
|
2014-05-07 03:48:59 +02:00
|
|
|
pp = <<-EOS
|
|
|
|
$a = ['a','b','c','d']
|
|
|
|
$o = fqdn_rotate($a)
|
|
|
|
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
|
|
|
|
EOS
|
|
|
|
|
|
|
|
apply_manifest(pp, :catch_failures => true) do |r|
|
|
|
|
expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
describe 'failure' do
|
|
|
|
it 'handles improper argument counts'
|
|
|
|
it 'handles non-numbers'
|
|
|
|
end
|
|
|
|
end
|