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
11 changed files
with
522 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'validates a single argument' do | ||
pp = <<-EOS | ||
$one = ['a', 'b'] | ||
validate_array($one) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates an multiple arguments' do | ||
pp = <<-EOS | ||
$one = ['a', 'b'] | ||
$two = [['c'], 'd'] | ||
validate_array($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a non-array' do | ||
{ | ||
%{validate_array({'a' => 'hash' })} => "Hash", | ||
%{validate_array('string')} => "String", | ||
%{validate_array(false)} => "FalseClass", | ||
%{validate_array(undef)} => "String" | ||
}.each do |pp,type| | ||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_augeas function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'prep' do | ||
it 'installs augeas for tests' | ||
end | ||
describe 'success' do | ||
it 'validates a single argument' do | ||
pp = <<-EOS | ||
$one = { 'a' => 1 } | ||
validate_hash($one) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates an multiple arguments' do | ||
pp = <<-EOS | ||
$one = { 'a' => 1 } | ||
$two = { 'b' => 2 } | ||
validate_hash($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a non-hash' do | ||
{ | ||
%{validate_hash('{ "not" => "hash" }')} => "String", | ||
%{validate_hash('string')} => "String", | ||
%{validate_hash(["array"])} => "Array", | ||
%{validate_hash(undef)} => "String", | ||
}.each do |pp,type| | ||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'validates a single argument' do | ||
pp = <<-EOS | ||
$one = true | ||
validate_bool($one) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates an multiple arguments' do | ||
pp = <<-EOS | ||
$one = true | ||
$two = false | ||
validate_bool($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a non-bool' do | ||
{ | ||
%{validate_bool('true')} => "String", | ||
%{validate_bool('false')} => "String", | ||
%{validate_bool([true])} => "Array", | ||
%{validate_bool(undef)} => "String", | ||
}.each do |pp,type| | ||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'validates a true command' do | ||
pp = <<-EOS | ||
$one = 'foo' | ||
if $::osfamily == 'windows' { | ||
$two = 'echo' #shell built-in | ||
} else { | ||
$two = '/bin/echo' | ||
} | ||
validate_cmd($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a fail command' do | ||
pp = <<-EOS | ||
$one = 'foo' | ||
if $::osfamily == 'windows' { | ||
$two = 'C:/aoeu' | ||
} else { | ||
$two = '/bin/aoeu' | ||
} | ||
validate_cmd($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :expect_failures => true) | ||
end | ||
it 'validates a fail command with a custom error message' do | ||
pp = <<-EOS | ||
$one = 'foo' | ||
if $::osfamily == 'windows' { | ||
$two = 'C:/aoeu' | ||
} else { | ||
$two = '/bin/aoeu' | ||
} | ||
validate_cmd($one,$two,"aoeu is dvorak) | ||
EOS | ||
|
||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/aoeu is dvorak/) | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
it 'handles improper argument types' | ||
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'validates a single argument' do | ||
pp = <<-EOS | ||
$one = { 'a' => 1 } | ||
validate_hash($one) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates an multiple arguments' do | ||
pp = <<-EOS | ||
$one = { 'a' => 1 } | ||
$two = { 'b' => 2 } | ||
validate_hash($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a non-hash' do | ||
{ | ||
%{validate_hash('{ "not" => "hash" }')} => "String", | ||
%{validate_hash('string')} => "String", | ||
%{validate_hash(["array"])} => "Array", | ||
%{validate_hash(undef)} => "String", | ||
}.each do |pp,type| | ||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_re function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'validates a string' do | ||
pp = <<-EOS | ||
$one = 'one' | ||
$two = '^one$' | ||
validate_re($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates an array' do | ||
pp = <<-EOS | ||
$one = 'one' | ||
$two = ['^one$', '^two'] | ||
validate_re($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a failed array' do | ||
pp = <<-EOS | ||
$one = 'one' | ||
$two = ['^two$', '^three'] | ||
validate_re($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :expect_failures => true) | ||
end | ||
it 'validates a failed array with a custom error message' do | ||
pp = <<-EOS | ||
$one = '3.4.3' | ||
$two = '^2.7' | ||
validate_re($one,$two,"The $puppetversion fact does not match 2.7") | ||
EOS | ||
|
||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/does not match/) | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
it 'handles improper argument types' | ||
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_slength function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'validates a single string max' do | ||
pp = <<-EOS | ||
$one = 'discombobulate' | ||
$two = 17 | ||
validate_slength($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates multiple string maxes' do | ||
pp = <<-EOS | ||
$one = ['discombobulate', 'moo'] | ||
$two = 17 | ||
validate_slength($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates min/max of strings in array' do | ||
pp = <<-EOS | ||
$one = ['discombobulate', 'moo'] | ||
$two = 17 | ||
$three = 3 | ||
validate_slength($one,$two,$three) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a single string max of incorrect length' do | ||
pp = <<-EOS | ||
$one = 'discombobulate' | ||
$two = 1 | ||
validate_slength($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :expect_failures => true) | ||
end | ||
it 'validates multiple string maxes of incorrect length' do | ||
pp = <<-EOS | ||
$one = ['discombobulate', 'moo'] | ||
$two = 3 | ||
validate_slength($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :expect_failures => true) | ||
end | ||
it 'validates multiple strings min/maxes of incorrect length' do | ||
pp = <<-EOS | ||
$one = ['discombobulate', 'moo'] | ||
$two = 17 | ||
$three = 10 | ||
validate_slength($one,$two,$three) | ||
EOS | ||
|
||
apply_manifest(pp, :expect_failures => true) | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
it 'handles improper first argument type' | ||
it 'handles non-strings in array of first argument' | ||
it 'handles improper second argument type' | ||
it 'handles improper third argument type' | ||
it 'handles negative ranges' | ||
it 'handles improper ranges' | ||
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'validates a single argument' do | ||
pp = <<-EOS | ||
$one = 'string' | ||
validate_string($one) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates an multiple arguments' do | ||
pp = <<-EOS | ||
$one = 'string' | ||
$two = 'also string' | ||
validate_string($one,$two) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
it 'validates a non-string' do | ||
{ | ||
%{validate_string({ 'a' => 'hash' })} => "Hash", | ||
%{validate_string(['array'])} => "Array", | ||
%{validate_string(false)} => "FalseClass", | ||
}.each do |pp,type| | ||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper number of arguments' | ||
end | ||
end |
Oops, something went wrong.