forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
317 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
it 'should accept a string' do | ||
pp = <<-EOS | ||
$input = '-34.56' | ||
$output = abs($input) | ||
notify { $output: } | ||
EOS | ||
describe 'success' do | ||
it 'should accept a string' do | ||
pp = <<-EOS | ||
$input = '-34.56' | ||
$output = abs($input) | ||
notify { $output: } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: 34.56/) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: 34.56/) | ||
end | ||
end | ||
end | ||
|
||
it 'should accept a float' do | ||
pp = <<-EOS | ||
$input = -34.56 | ||
$output = abs($input) | ||
notify { $output: } | ||
EOS | ||
it 'should accept a float' do | ||
pp = <<-EOS | ||
$input = -34.56 | ||
$output = abs($input) | ||
notify { $output: } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: 34.56/) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: 34.56/) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,48 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
it 'should create an empty array' do | ||
pp = <<-EOS | ||
$input = '' | ||
$output = any2array($input) | ||
validate_array($output) | ||
notify { "Output: ${output}": } | ||
EOS | ||
describe 'success' do | ||
it 'should create an empty array' do | ||
pp = <<-EOS | ||
$input = '' | ||
$output = any2array($input) | ||
validate_array($output) | ||
notify { "Output: ${output}": } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: Output: /) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: Output: /) | ||
end | ||
end | ||
end | ||
|
||
it 'should leave arrays modified' do | ||
pp = <<-EOS | ||
$input = ['test', 'array'] | ||
$output = any2array($input) | ||
validate_array($output) | ||
notify { "Output: ${output}": } | ||
EOS | ||
it 'should leave arrays modified' do | ||
pp = <<-EOS | ||
$input = ['test', 'array'] | ||
$output = any2array($input) | ||
validate_array($output) | ||
notify { "Output: ${output}": } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: Output: testarray/) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: Output: testarray/) | ||
end | ||
end | ||
end | ||
|
||
it 'should turn a hash into an array' do | ||
pp = <<-EOS | ||
$input = {'test' => 'array'} | ||
$output = any2array($input) | ||
it 'should turn a hash into an array' do | ||
pp = <<-EOS | ||
$input = {'test' => 'array'} | ||
$output = any2array($input) | ||
validate_array($output) | ||
# Check each element of the array is a plain string. | ||
validate_string($output[0]) | ||
validate_string($output[1]) | ||
notify { "Output: ${output}": } | ||
EOS | ||
validate_array($output) | ||
# Check each element of the array is a plain string. | ||
validate_string($output[0]) | ||
validate_string($output[1]) | ||
notify { "Output: ${output}": } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: Output: testarray/) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: Output: testarray/) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
it 'should encode then decode a string' do | ||
pp = <<-EOS | ||
$encodestring = base64('encode', 'thestring') | ||
$decodestring = base64('decode', $encodestring) | ||
notify { $decodestring: } | ||
EOS | ||
describe 'success' do | ||
it 'should encode then decode a string' do | ||
pp = <<-EOS | ||
$encodestring = base64('encode', 'thestring') | ||
$decodestring = base64('decode', $encodestring) | ||
notify { $decodestring: } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/thestring/) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/thestring/) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
it 'should capitalize the first letter of a string' do | ||
pp = <<-EOS | ||
$input = 'this is a string' | ||
$output = capitalize($input) | ||
notify { $output: } | ||
EOS | ||
describe 'success' do | ||
it 'should capitalize the first letter of a string' do | ||
pp = <<-EOS | ||
$input = 'this is a string' | ||
$output = capitalize($input) | ||
notify { $output: } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: This is a string/) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: This is a string/) | ||
end | ||
end | ||
end | ||
|
||
it 'should capitalize the first letter of an array of strings' do | ||
pp = <<-EOS | ||
$input = ['this', 'is', 'a', 'string'] | ||
$output = capitalize($input) | ||
notify { $output: } | ||
EOS | ||
it 'should capitalize the first letter of an array of strings' do | ||
pp = <<-EOS | ||
$input = ['this', 'is', 'a', 'string'] | ||
$output = capitalize($input) | ||
notify { $output: } | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: This/) | ||
expect(r.stdout).to match(/Notice: Is/) | ||
expect(r.stdout).to match(/Notice: A/) | ||
expect(r.stdout).to match(/Notice: String/) | ||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: This/) | ||
expect(r.stdout).to match(/Notice: Is/) | ||
expect(r.stdout).to match(/Notice: A/) | ||
expect(r.stdout).to match(/Notice: String/) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
it 'should eat the newline' do | ||
pp = <<-EOS | ||
$input = "test\n" | ||
if size($input) != 5 { | ||
fail("Size of ${input} is not 5.") | ||
} | ||
$output = chomp($input) | ||
if size($output) != 4 { | ||
fail("Size of ${input} is not 4.") | ||
} | ||
EOS | ||
describe 'success' do | ||
it 'should eat the newline' do | ||
pp = <<-EOS | ||
$input = "test\n" | ||
if size($input) != 5 { | ||
fail("Size of ${input} is not 5.") | ||
} | ||
$output = chomp($input) | ||
if size($output) != 4 { | ||
fail("Size of ${input} is not 4.") | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
it 'should eat the last character' do | ||
pp = <<-EOS | ||
$input = "test" | ||
if size($input) != 4 { | ||
fail("Size of ${input} is not 4.") | ||
} | ||
$output = chop($input) | ||
if size($output) != 3 { | ||
fail("Size of ${input} is not 3.") | ||
} | ||
EOS | ||
describe 'success' do | ||
it 'should eat the last character' do | ||
pp = <<-EOS | ||
$input = "test" | ||
if size($input) != 4 { | ||
fail("Size of ${input} is not 4.") | ||
} | ||
$output = chop($input) | ||
if size($output) != 3 { | ||
fail("Size of ${input} is not 3.") | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
it 'should eat the last two characters of \r\n' do | ||
pp = <<-EOS | ||
$input = "test\r\n" | ||
if size($input) != 6 { | ||
fail("Size of ${input} is not 6.") | ||
} | ||
$output = chop($input) | ||
if size($output) != 4 { | ||
fail("Size of ${input} is not 4.") | ||
} | ||
EOS | ||
it 'should eat the last two characters of \r\n' do | ||
pp = <<-EOS | ||
$input = "test\r\n" | ||
if size($input) != 6 { | ||
fail("Size of ${input} is not 6.") | ||
} | ||
$output = chop($input) | ||
if size($output) != 4 { | ||
fail("Size of ${input} is not 4.") | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
it 'should not fail on empty strings' do | ||
pp = <<-EOS | ||
$input = "" | ||
$output = chop($input) | ||
EOS | ||
it 'should not fail on empty strings' do | ||
pp = <<-EOS | ||
$input = "" | ||
$output = chop($input) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
end | ||
end |
Oops, something went wrong.