Skip to content

Commit fcbd3f2

Browse files
committed
fqdn_rotate: Add acceptance tests for custom seeds
1 parent b436216 commit fcbd3f2

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

spec/acceptance/fqdn_rotate_spec.rb

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
shell("mkdir -p '#{facts_d}'")
2828
end
2929
end
30-
it 'fqdn_rotates floats' do
30+
it 'rotates arrays' do
3131
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
3232
pp = <<-EOS
3333
$a = ['a','b','c','d']
@@ -39,9 +39,47 @@
3939
expect(r.stdout).to match(/fqdn_rotate is \["d", "a", "b", "c"\]/)
4040
end
4141
end
42+
it 'rotates arrays with custom seeds' do
43+
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
44+
pp = <<-EOS
45+
$a = ['a','b','c','d']
46+
$s = 'seed'
47+
$o = fqdn_rotate($a, $s)
48+
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
49+
EOS
50+
51+
apply_manifest(pp, :catch_failures => true) do |r|
52+
expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
53+
end
54+
end
55+
it 'rotates strings' do
56+
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
57+
pp = <<-EOS
58+
$a = 'abcd'
59+
$o = fqdn_rotate($a)
60+
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
61+
EOS
62+
63+
apply_manifest(pp, :catch_failures => true) do |r|
64+
expect(r.stdout).to match(/fqdn_rotate is "dabc"/)
65+
end
66+
end
67+
it 'rotates strings with custom seeds' do
68+
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
69+
pp = <<-EOS
70+
$a = 'abcd'
71+
$s = 'seed'
72+
$o = fqdn_rotate($a, $s)
73+
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
74+
EOS
75+
76+
apply_manifest(pp, :catch_failures => true) do |r|
77+
expect(r.stdout).to match(/fqdn_rotate is "cdab"/)
78+
end
79+
end
4280
end
4381
describe 'failure' do
4482
it 'handles improper argument counts'
45-
it 'handles non-numbers'
83+
it 'handles invalid arguments'
4684
end
4785
end

0 commit comments

Comments
 (0)