|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'python::dotfile', type: :define do |
| 4 | + on_supported_os.each do |os, facts| |
| 5 | + context("on #{os} ") do |
| 6 | + let :facts do |
| 7 | + facts |
| 8 | + end |
| 9 | + |
| 10 | + describe 'dotfile as' do |
| 11 | + context 'fails with empty string filename' do |
| 12 | + let(:title) { '' } |
| 13 | + |
| 14 | + it { is_expected.to raise_error(%r{Evaluation Error: Empty string title at 0. Title strings must have a length greater than zero.}) } |
| 15 | + end |
| 16 | + context 'fails with incorrect mode' do |
| 17 | + let(:title) { '/etc/pip.conf' } |
| 18 | + let(:params) { { mode: 'not-a-mode' } } |
| 19 | + |
| 20 | + it { is_expected.to raise_error(%r{Evaluation Error: Error while evaluating a Resource}) } |
| 21 | + end |
| 22 | + context 'succeeds with filename in existing path' do |
| 23 | + let(:title) { '/etc/pip.conf' } |
| 24 | + |
| 25 | + it { is_expected.to contain_file('/etc/pip.conf').with_mode('0644') } |
| 26 | + end |
| 27 | + context 'succeeds with filename in a non-existing path' do |
| 28 | + let(:title) { '/home/someuser/.pip/pip.conf' } |
| 29 | + |
| 30 | + it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command('install -o root -g root -d /home/someuser/.pip') } |
| 31 | + it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_mode('0644') } |
| 32 | + end |
| 33 | + context 'succeeds when set owner' do |
| 34 | + let(:title) { '/home/someuser/.pip/pip.conf' } |
| 35 | + let(:params) { { owner: 'someuser' } } |
| 36 | + |
| 37 | + it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command('install -o someuser -g root -d /home/someuser/.pip') } |
| 38 | + it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_owner('someuser') } |
| 39 | + end |
| 40 | + context 'succeeds when set group set' do |
| 41 | + let(:title) { '/home/someuser/.pip/pip.conf' } |
| 42 | + let(:params) { { group: 'somegroup' } } |
| 43 | + |
| 44 | + it { is_expected.to contain_exec('create /home/someuser/.pip/pip.conf\'s parent dir').with_command('install -o root -g somegroup -d /home/someuser/.pip') } |
| 45 | + it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_group('somegroup') } |
| 46 | + end |
| 47 | + end |
| 48 | + end |
| 49 | + end |
| 50 | +end |
0 commit comments