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.
Merge pull request redhat-openstack#247 from hunner/more_tests
Adding more spec coverage
- Loading branch information
Showing
188 changed files
with
1,751 additions
and
11 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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,25 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'should delete elements of the hash' do | ||
pp = <<-EOS | ||
$a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' } | ||
$b = { 'a' => 'A', 'B' => 'C' } | ||
$o = delete_values($a, 'B') | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles non-hash arguments' | ||
it 'handles improper argument counts' | ||
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,26 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'returns non-duplicates in the first array' do | ||
pp = <<-EOS | ||
$a = ['a','b','c'] | ||
$b = ['b','c','d'] | ||
$c = ['a'] | ||
$o = difference($a, $b) | ||
if $o == $c { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles non-array arguments' | ||
it 'handles improper argument counts' | ||
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,42 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'dirname function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
context 'absolute path' do | ||
it 'returns the dirname' do | ||
pp = <<-EOS | ||
$a = '/path/to/a/file.txt' | ||
$b = '/path/to/a' | ||
$o = dirname($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
context 'relative path' do | ||
it 'returns the dirname' do | ||
pp = <<-EOS | ||
$a = 'path/to/a/file.txt' | ||
$b = 'path/to/a' | ||
$o = dirname($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper argument counts' | ||
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 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'downcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'returns the downcase' do | ||
pp = <<-EOS | ||
$a = 'AOEU' | ||
$b = 'aoeu' | ||
$o = downcase($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
it 'doesn\'t affect lowercase words' do | ||
pp = <<-EOS | ||
$a = 'aoeu aoeu' | ||
$b = 'aoeu aoeu' | ||
$o = downcase($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper argument counts' | ||
it 'handles non-strings' | ||
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 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'recognizes empty strings' do | ||
pp = <<-EOS | ||
$a = '' | ||
$b = true | ||
$o = empty($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
it 'recognizes non-empty strings' do | ||
pp = <<-EOS | ||
$a = 'aoeu' | ||
$b = false | ||
$o = empty($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper argument counts' | ||
it 'handles non-strings' | ||
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,24 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'ensure_packages function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'ensure_packages a package' do | ||
apply_manifest('package { "zsh": ensure => absent, }') | ||
pp = <<-EOS | ||
$a = "zsh" | ||
ensure_packages($a) | ||
EOS | ||
|
||
apply_manifest(pp, :expect_changes => true) do |r| | ||
expect(r.stdout).to match(/Package\[zsh\]\/ensure: created/) | ||
end | ||
end | ||
it 'ensures a package already declared' | ||
it 'takes defaults arguments' | ||
end | ||
describe 'failure' do | ||
it 'handles no arguments' | ||
it 'handles non strings' | ||
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,24 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'ensure_resource function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'ensure_resource a package' do | ||
apply_manifest('package { "zsh": ensure => absent, }') | ||
pp = <<-EOS | ||
$a = "zsh" | ||
ensure_resource('package', $a) | ||
EOS | ||
|
||
apply_manifest(pp, :expect_changes => true) do |r| | ||
expect(r.stdout).to match(/Package\[zsh\]\/ensure: created/) | ||
end | ||
end | ||
it 'ensures a resource already declared' | ||
it 'takes defaults arguments' | ||
end | ||
describe 'failure' do | ||
it 'handles no arguments' | ||
it 'handles non strings' | ||
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 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'flatten function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'flattens arrays' do | ||
pp = <<-EOS | ||
$a = ["a","b",["c",["d","e"],"f","g"]] | ||
$b = ["a","b","c","d","e","f","g"] | ||
$o = flatten($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
it 'does not affect flat arrays' do | ||
pp = <<-EOS | ||
$a = ["a","b","c","d","e","f","g"] | ||
$b = ["a","b","c","d","e","f","g"] | ||
$o = flatten($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper argument counts' | ||
it 'handles non-strings' | ||
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 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'floor function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'floors floats' do | ||
pp = <<-EOS | ||
$a = 12.8 | ||
$b = 12 | ||
$o = floor($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
it 'floors integers' do | ||
pp = <<-EOS | ||
$a = 7 | ||
$b = 7 | ||
$o = floor($a) | ||
if $o == $b { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper argument counts' | ||
it 'handles non-numbers' | ||
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,33 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
let(:facts_d) do | ||
if fact('is_pe') == "true" | ||
'/etc/puppetlabs/facter/facts.d' | ||
else | ||
'/etc/facter/facts.d' | ||
end | ||
end | ||
after :each do | ||
shell("if [ -f #{facts_d}/fqdn.txt ] ; then rm #{facts_d}/fqdn.txt ; fi") | ||
end | ||
it 'fqdn_rotates floats' do | ||
shell("echo 'fqdn=fakehost.localdomain' > #{facts_d}/fqdn.txt") | ||
pp = <<-EOS | ||
$a = ['a','b','c','d'] | ||
$o = fqdn_rotate($a) | ||
notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/) | ||
end | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper argument counts' | ||
it 'handles non-numbers' | ||
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,41 @@ | ||
#! /usr/bin/env ruby -S rspec | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'get_module_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do | ||
describe 'success' do | ||
it 'get_module_paths stdlib' do | ||
pp = <<-EOS | ||
$a = $::is_pe ? { | ||
'true' => '/opt/puppet/share/puppet/modules/stdlib', | ||
'false' => '/etc/puppet/modules/stdlib', | ||
} | ||
$o = get_module_path('stdlib') | ||
if $o == $a { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :catch_failures => true) do |r| | ||
expect(r.stdout).to match(/Notice: output correct/) | ||
end | ||
end | ||
it 'get_module_paths dne' do | ||
pp = <<-EOS | ||
$a = $::is_pe ? { | ||
'true' => '/etc/puppetlabs/puppet/modules/dne', | ||
'false' => '/etc/puppet/modules/dne', | ||
} | ||
$o = get_module_path('dne') | ||
if $o == $a { | ||
notify { 'output correct': } | ||
} | ||
EOS | ||
|
||
apply_manifest(pp, :expect_failures => true) | ||
end | ||
end | ||
describe 'failure' do | ||
it 'handles improper argument counts' | ||
it 'handles non-numbers' | ||
end | ||
end |
Oops, something went wrong.