]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/staging/spec/defines/staging_extract_spec.rb
add nanliu/staging to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / staging / spec / defines / staging_extract_spec.rb
1 require 'spec_helper'
2 describe 'staging::extract', :type => :define do
3
4   # forcing a more sane caller_module_name to match real usage.
5   let(:facts) { { :caller_module_name => 'spec',
6                   :osfamily           => 'RedHat',
7                   :path               => '/usr/local/bin:/usr/bin:/bin' } }
8
9   describe 'when deploying tar.gz' do
10     let(:title) { 'sample.tar.gz' }
11     let(:params) { { :target => '/opt' } }
12
13     it {
14       should contain_file('/opt/staging')
15       should contain_exec('extract sample.tar.gz').with({
16         :command => 'tar xzf /opt/staging/spec/sample.tar.gz',
17         :path    => '/usr/local/bin:/usr/bin:/bin',
18         :cwd     => '/opt',
19         :creates => '/opt/sample'
20       })
21     }
22   end
23
24   describe 'when deploying tar.gz with strip' do
25     let(:title) { 'sample.tar.gz' }
26     let(:params) { { :target => '/opt',
27                      :strip  => 1, } }
28
29     it {
30       should contain_file('/opt/staging')
31       should contain_exec('extract sample.tar.gz').with({
32         :command => 'tar xzf /opt/staging/spec/sample.tar.gz --strip=1',
33         :path    => '/usr/local/bin:/usr/bin:/bin',
34         :cwd     => '/opt',
35         :creates => '/opt/sample'
36       })
37     }
38   end
39
40   describe 'when deploying zip' do
41     let(:title) { 'sample.zip' }
42     let(:params) { { :target => '/opt' } }
43
44     it { should contain_file('/opt/staging')
45       should contain_exec('extract sample.zip').with({
46         :command => 'unzip /opt/staging/spec/sample.zip',
47         :path    => '/usr/local/bin:/usr/bin:/bin',
48         :cwd     => '/opt',
49         :creates => '/opt/sample'
50       })
51     }
52   end
53
54   describe 'when deploying zip with strip (noop)' do
55     let(:title) { 'sample.zip' }
56     let(:params) { { :target => '/opt',
57                      :strip  => 1, } }
58
59     it { should contain_file('/opt/staging')
60       should contain_exec('extract sample.zip').with({
61         :command => 'unzip /opt/staging/spec/sample.zip',
62         :path    => '/usr/local/bin:/usr/bin:/bin',
63         :cwd     => '/opt',
64         :creates => '/opt/sample'
65       })
66     }
67   end
68
69   describe 'when deploying war' do
70     let(:title) { 'sample.war' }
71     let(:params) { { :target => '/opt' } }
72
73     it { should contain_file('/opt/staging')
74       should contain_exec('extract sample.war').with({
75         :command => 'jar xf /opt/staging/spec/sample.war',
76         :path    => '/usr/local/bin:/usr/bin:/bin',
77         :cwd     => '/opt',
78         :creates => '/opt/sample'
79       })
80     }
81   end
82
83   describe 'when deploying war with strip (noop)' do
84     let(:title) { 'sample.war' }
85     let(:params) { { :target => '/opt',
86                      :strip  => 1, } }
87
88     it { should contain_file('/opt/staging')
89       should contain_exec('extract sample.war').with({
90         :command => 'jar xf /opt/staging/spec/sample.war',
91         :path    => '/usr/local/bin:/usr/bin:/bin',
92         :cwd     => '/opt',
93         :creates => '/opt/sample'
94       })
95     }
96   end
97
98   describe 'when deploying unknown' do
99      let(:title) { 'sample.zzz'}
100      let(:params) { { :target => '/opt' } }
101
102      it { expect { should contain_exec("exec sample.zzz") }.to raise_error(Puppet::Error) }
103   end
104 end