Skip to content

Commit ed0f134

Browse files
authored
Merge pull request #446 from gdubicki/fix_python_dotfile
Fix $filename and $mode types in python::dotfile
2 parents 66ad130 + 40a8949 commit ed0f134

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

manifests/dotfile.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
#
2525
define python::dotfile (
2626
Enum['absent', 'present'] $ensure = 'present',
27-
Stdlib::Filemode $filename = $title,
27+
String[1] $filename = $title,
2828
String[1] $owner = 'root',
2929
String[1] $group = 'root',
30-
String[1] $mode = '0644',
30+
Stdlib::Filemode $mode = '0644',
3131
Hash $config = {},
3232
) {
3333
$parent_dir = dirname($filename)

spec/defines/dotfile_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

spec/defines/pyvenv_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe 'python::pyvenv', type: :define do
44
on_supported_os.each do |os, facts|
5-
context "on #{os} " do
5+
context("on #{os} ") do
66
let :facts do
77
facts
88
end

0 commit comments

Comments
 (0)