Skip to content

Commit 09b427b

Browse files
committed
Merge pull request #466 from elyscape/fix/improve_fqdn_acceptance_tests
Improve fqdn_rotate/fqdn_rand_string acceptance tests
2 parents f5f72f4 + 98c2f28 commit 09b427b

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

spec/acceptance/fqdn_rand_string_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@
3939
expect(r.stdout).to match(/fqdn_rand_string is "7oDp0KOr1b"/)
4040
end
4141
end
42+
it 'generates random alphanumeric strings with custom charsets' do
43+
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
44+
pp = <<-eos
45+
$l = 10
46+
$c = '0123456789'
47+
$o = fqdn_rand_string($l, $c)
48+
notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
49+
eos
50+
51+
apply_manifest(pp, :catch_failures => true) do |r|
52+
expect(r.stdout).to match(/fqdn_rand_string is "7203048515"/)
53+
end
54+
end
4255
it 'generates random alphanumeric strings with custom seeds' do
4356
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
4457
pp = <<-eos
@@ -52,6 +65,20 @@
5265
expect(r.stdout).to match(/fqdn_rand_string is "3HS4mbuI3E"/)
5366
end
5467
end
68+
it 'generates random alphanumeric strings with custom charsets and seeds' do
69+
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
70+
pp = <<-eos
71+
$l = 10
72+
$c = '0123456789'
73+
$s = 'seed'
74+
$o = fqdn_rand_string($l, $c, $s)
75+
notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
76+
eos
77+
78+
apply_manifest(pp, :catch_failures => true) do |r|
79+
expect(r.stdout).to match(/fqdn_rand_string is "3104058232"/)
80+
end
81+
end
5582
end
5683
describe 'failure' do
5784
it 'handles improper argument counts'

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)