Skip to content

Commit

Permalink
Fix $filename and $mode types
Browse files Browse the repository at this point in the history
erroneously changed in a990c0b
and add tests to ensure this kind
of breakage will not repeat
  • Loading branch information
Greg Dubicki committed Nov 4, 2018
1 parent 13b725d commit 5dd598e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions manifests/dotfile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#
define python::dotfile (
Enum['absent', 'present'] $ensure = 'present',
Stdlib::Filemode $filename = $title,
String[1] $filename = $title,
String[1] $owner = 'root',
String[1] $group = 'root',
String[1] $mode = '0644',
Stdlib::Filemode $mode = '0644',
Hash $config = {},
) {
$parent_dir = dirname($filename)
Expand Down
36 changes: 36 additions & 0 deletions spec/defines/dotfile_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'spec_helper'

describe 'python::dotfile', type: :define do
on_supported_os.each do |os, facts|
context("on #{os} ") do
let :facts do
facts
end

describe 'dotfile as' do
context 'fails with empty string filename' do
let(:title) { '' }

it { is_expected.to raise_error(%r{Evaluation Error: Empty string title at 0. Title strings must have a length greater than zero.}) }
end
context 'fails with incorrect mode' do
let(:title) { '/etc/pip.conf' }
let(:params) { { mode: 'not-a-mode' } }

it { is_expected.to raise_error(%r{Evaluation Error: Error while evaluating a Resource}) }
end
context 'succeeds with filename in existing path' do
let(:title) { '/etc/pip.conf' }

it { is_expected.to contain_file('/etc/pip.conf').with_mode('0644') }
end
context 'succeeds with filename in a non-existing path' do
let(:title) { '/home/someuser/.pip/pip.conf' }

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') }
it { is_expected.to contain_file('/home/someuser/.pip/pip.conf').with_mode('0644') }
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/defines/pyvenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'python::pyvenv', type: :define do
on_supported_os.each do |os, facts|
context "on #{os} " do
context("on #{os} ") do
let :facts do
facts
end
Expand Down

0 comments on commit 5dd598e

Please sign in to comment.