|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
| 3 | +shared_examples 'remote_file' do |
| 4 | + it { is_expected.to contain_exec('mkdir -p /tmp') } |
| 5 | +end |
| 6 | + |
3 | 7 | describe 'foreman_proxy::remote_file' do |
4 | 8 | let(:title) { '/tmp/a' } |
5 | 9 |
|
6 | | - let(:params) do |
7 | | - { |
8 | | - remote_location: 'https://example.com/tmp/a', |
9 | | - mode: '0664' |
10 | | - } |
11 | | - end |
| 10 | + context 'without owner/group params' do |
| 11 | + let(:params) do |
| 12 | + { |
| 13 | + remote_location: 'https://example.com/tmp/a', |
| 14 | + mode: '0664' |
| 15 | + } |
| 16 | + end |
12 | 17 |
|
13 | | - context 'default scenario' do |
14 | | - it { is_expected.to contain_exec('mkdir -p /tmp') } |
| 18 | + context 'default scenario' do |
| 19 | + include_examples 'remote_file' |
15 | 20 |
|
16 | | - it do |
17 | | - is_expected.to contain_file('/tmp/a') |
18 | | - .with_source('https://example.com/tmp/a') |
19 | | - .with_mode('0664') |
20 | | - .that_requires('Exec[mkdir -p /tmp]') |
| 21 | + it do |
| 22 | + is_expected.to contain_file('/tmp/a').with( |
| 23 | + source: 'https://example.com/tmp/a', |
| 24 | + mode: '0664', |
| 25 | + owner: nil, |
| 26 | + group: nil, |
| 27 | + ).without( |
| 28 | + ).that_requires('Exec[mkdir -p /tmp]') |
| 29 | + end |
| 30 | + end |
| 31 | + |
| 32 | + context 'with parent file defined' do |
| 33 | + let :pre_condition do |
| 34 | + "file { '/tmp': }" |
| 35 | + end |
| 36 | + |
| 37 | + include_examples 'remote_file' |
| 38 | + |
| 39 | + it { is_expected.to contain_exec('mkdir -p /tmp').that_requires('File[/tmp]') } |
21 | 40 | end |
22 | 41 | end |
23 | 42 |
|
24 | | - context 'with parent file defined' do |
25 | | - let :pre_condition do |
26 | | - "file { '/tmp': }" |
| 43 | + context 'with owner/group params' do |
| 44 | + let(:params) do |
| 45 | + { |
| 46 | + remote_location: 'https://example.com/tmp/a', |
| 47 | + mode: '0664', |
| 48 | + owner: 'foo', |
| 49 | + group: 'bar', |
| 50 | + } |
27 | 51 | end |
28 | 52 |
|
29 | | - it { is_expected.to contain_exec('mkdir -p /tmp').that_requires('File[/tmp]') } |
| 53 | + include_examples 'remote_file' |
| 54 | + |
| 55 | + it do |
| 56 | + is_expected.to contain_file('/tmp/a').with( |
| 57 | + source: 'https://example.com/tmp/a', |
| 58 | + mode: '0664', |
| 59 | + owner: 'foo', |
| 60 | + group: 'bar', |
| 61 | + ).that_requires('Exec[mkdir -p /tmp]') |
| 62 | + end |
30 | 63 | end |
31 | 64 | end |
0 commit comments