2889fe82247f7581157c5828a59e8b5dfcba23db
[mirror/dsa-puppet.git] / 3rdparty / modules / archive / spec / defines / go_spec.rb
1 require 'spec_helper'
2
3 describe 'archive::go' do
4   let(:facts) { { os: { family: 'RedHat' }, puppetversion: '4.4.0' } }
5
6   before do
7     MockFunction.new('go_md5') do |f|
8       f.stub.returns('0d4f4b4b039c10917cfc49f6f6be71e4')
9     end
10   end
11
12   context 'go archive with defaults' do
13     let(:title) { '/opt/app/example.zip' }
14     let(:params) do
15       {
16         server: 'home.lan',
17         port: 8081,
18         url_path: 'go/example.zip',
19         md5_url_path: 'go/example.zip/checksum',
20         username: 'username',
21         password: 'password'
22       }
23     end
24
25     it do
26       is_expected.to contain_archive('/opt/app/example.zip').with(
27         path: '/opt/app/example.zip',
28         source: 'http://home.lan:8081/go/example.zip',
29         checksum: '0d4f4b4b039c10917cfc49f6f6be71e4',
30         checksum_type: 'md5'
31       )
32     end
33
34     it do
35       is_expected.to contain_file('/opt/app/example.zip').with(
36         owner: '0',
37         group: '0',
38         mode: '0640',
39         require: 'Archive[/opt/app/example.zip]'
40       )
41     end
42   end
43
44   context 'go archive with path' do
45     let(:title) { 'example.zip' }
46     let(:params) do
47       {
48         archive_path: '/opt/app',
49         server: 'home.lan',
50         port: 8081,
51         url_path: 'go/example.zip',
52         md5_url_path: 'go/example.zip/checksum',
53         username: 'username',
54         password: 'password',
55         owner: 'app',
56         group: 'app',
57         mode: '0400'
58       }
59     end
60
61     it do
62       is_expected.to contain_archive('/opt/app/example.zip').with(
63         path: '/opt/app/example.zip',
64         source: 'http://home.lan:8081/go/example.zip',
65         checksum: '0d4f4b4b039c10917cfc49f6f6be71e4',
66         checksum_type: 'md5'
67       )
68     end
69
70     it do
71       is_expected.to contain_file('/opt/app/example.zip').with(
72         owner: 'app',
73         group: 'app',
74         mode: '0400',
75         require: 'Archive[/opt/app/example.zip]'
76       )
77     end
78   end
79 end