From 1343de3817ab64b39ccf4d76ab73f1024f3db0a7 Mon Sep 17 00:00:00 2001 From: Thomas Van Doren Date: Mon, 4 Jun 2012 20:45:19 -0700 Subject: Add recurse option to tftp::file class. Update rspec tests to assert the value of recurse in various cases. --- spec/defines/tftp_file_spec.rb | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'spec/defines/tftp_file_spec.rb') diff --git a/spec/defines/tftp_file_spec.rb b/spec/defines/tftp_file_spec.rb index 00072e6..8caa65b 100644 --- a/spec/defines/tftp_file_spec.rb +++ b/spec/defines/tftp_file_spec.rb @@ -10,10 +10,11 @@ describe 'tftp::file' do it { should include_class('tftp') } it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'file', - 'owner' => 'tftp', - 'group' => 'tftp', - 'mode' => '0644' + 'ensure' => 'file', + 'recurse' => false, + 'owner' => 'tftp', + 'group' => 'tftp', + 'mode' => '0644' }) } end @@ -23,27 +24,30 @@ describe 'tftp::file' do it { should include_class('tftp') } it { should contain_file('/var/lib/tftpboot/sample').with({ - 'ensure' => 'file', - 'owner' => 'tftp', - 'group' => 'tftp', - 'mode' => '0644' + 'ensure' => 'file', + 'recurse' => false, + 'owner' => 'tftp', + 'group' => 'tftp', + 'mode' => '0644' }) } end describe 'when deploying with parameters' do - let(:params) { {:ensure => 'directory', - :owner => 'root', - :group => 'root', - :mode => '0755' }} + let(:params) { {:ensure => 'directory', + :recurse => true, + :owner => 'root', + :group => 'root', + :mode => '0755' }} let(:facts) { { :operatingsystem => 'Debian', :path => '/usr/local/bin:/usr/bin:/bin', } } it { should include_class('tftp') } it { should contain_file('/srv/tftp/sample').with({ - 'ensure' => 'directory', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0755' + 'ensure' => 'directory', + 'recurse' => true, + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0755' }) } end end -- cgit v1.2.3 From 2c22a9b5fd0336681a4fca9d8f875b15950fdacb Mon Sep 17 00:00:00 2001 From: Thomas Van Doren Date: Fri, 15 Jun 2012 19:34:53 -0700 Subject: Add spec tests for recurse params. One test verifies the defaults for recurse, purge, replace, recurselimit when they are not provided. The other test ensure that setting them in the tftp:file definition correlates to the params getting set on the file. --- spec/defines/tftp_file_spec.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'spec/defines/tftp_file_spec.rb') diff --git a/spec/defines/tftp_file_spec.rb b/spec/defines/tftp_file_spec.rb index 8caa65b..6a032c0 100644 --- a/spec/defines/tftp_file_spec.rb +++ b/spec/defines/tftp_file_spec.rb @@ -50,4 +50,41 @@ describe 'tftp::file' do 'mode' => '0755' }) } end + + describe 'when deploying without recurse parameters' do + let(:facts) { {:operatingsystem => 'Debian', + :path => '/usr/local/bin:/usr/bin:/bin', } } + + it { should include_class('tftp') } + it { should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'file', + 'recurse' => false, + 'purge' => nil, + 'replace' => nil, + 'recurselimit' => nil + }) } + end + + describe 'when deploying with recurse parameters' do + let(:params) { {:ensure => 'directory', + :recurse => true, + :mode => '0755', + :recurselimit => 42, + :purge => true, + :replace => false }} + let(:facts) { {:operatingsystem => 'Debian', + :path => '/usr/local/bin:/usr/bin:/bin', }} + + it { should include_class('tftp') } + it { should contain_file('/srv/tftp/sample').with({ + 'ensure' => 'directory', + 'recurse' => true, + 'owner' => 'tftp', + 'group' => 'tftp', + 'mode' => '0755', + 'recurselimit' => 42, + 'purge' => true, + 'replace' => false, + }) } + end end -- cgit v1.2.3