4fa2b456a236d75a9bcaa85f9c1676143eac2d69
[mirror/dsa-puppet.git] / 3rdparty / modules / archive / spec / defines / artifactory_spec.rb
1 require 'spec_helper'
2
3 describe 'archive::artifactory' do
4   let(:facts) { { os: { family: 'RedHat' }, puppetversion: '4.4.0' } }
5
6   # Mock Puppet V4 API ruby function with a puppet language function equivalent
7   let(:pre_condition) do
8     'function archive::artifactory_checksum($url,$type) { return \'0d4f4b4b039c10917cfc49f6f6be71e4\' }'
9   end
10
11   context 'artifactory archive with defaults' do
12     let(:title) { '/opt/app/example.zip' }
13     let(:params) do
14       {
15         url: 'http://home.lan:8081/artifactory/path/example.zip'
16       }
17     end
18
19     it do
20       is_expected.to contain_archive('/opt/app/example.zip').with(
21         path: '/opt/app/example.zip',
22         source: 'http://home.lan:8081/artifactory/path/example.zip',
23         checksum: '0d4f4b4b039c10917cfc49f6f6be71e4',
24         checksum_type: 'sha1'
25       )
26     end
27
28     it do
29       is_expected.to contain_file('/opt/app/example.zip').with(
30         owner: '0',
31         group: '0',
32         mode: '0640',
33         require: 'Archive[/opt/app/example.zip]'
34       )
35     end
36   end
37
38   context 'artifactory archive with path' do
39     let(:title) { 'example.zip' }
40     let(:params) do
41       {
42         archive_path: '/opt/app',
43         url: 'http://home.lan:8081/artifactory/path/example.zip',
44         owner: 'app',
45         group: 'app',
46         mode: '0400'
47       }
48     end
49
50     it do
51       is_expected.to contain_archive('/opt/app/example.zip').with(
52         path: '/opt/app/example.zip',
53         source: 'http://home.lan:8081/artifactory/path/example.zip',
54         checksum: '0d4f4b4b039c10917cfc49f6f6be71e4',
55         checksum_type: 'sha1'
56       )
57     end
58
59     it do
60       is_expected.to contain_file('/opt/app/example.zip').with(
61         owner: 'app',
62         group: 'app',
63         mode: '0400',
64         require: 'Archive[/opt/app/example.zip]'
65       )
66     end
67   end
68 end