Skip to content

Commit 98c2f28

Browse files
committed
fqdn_rand_string: Add acceptance tests for custom charsets
1 parent 84279e9 commit 98c2f28

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
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'

0 commit comments

Comments
 (0)