X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fconcat%2Fspec%2Funit%2Fdefines%2Fconcat_fragment_spec.rb;h=4815b93842764da883f1ffe1455b9844b0aac5df;hb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f;hp=317b02cdc6426ab04fca795bdaaa6ddec5de9516;hpb=23d29143ac40015ce61cf83a4067466f8f7d66dc;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb b/3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb index 317b02cdc..4815b9384 100644 --- a/3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb +++ b/3rdparty/modules/concat/spec/unit/defines/concat_fragment_spec.rb @@ -11,9 +11,6 @@ describe 'concat::fragment', :type => :define do :order => 10, }.merge(params) - id = 'root' - gid = 'root' - let(:title) { title } let(:params) { params } let(:pre_condition) do @@ -51,7 +48,7 @@ describe 'concat::fragment', :type => :define do let(:params) {{ :target => false }} it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /parameter 'target' expects a .*String.*/) end end end # target => @@ -71,7 +68,7 @@ describe 'concat::fragment', :type => :define do let(:params) {{ :content => false, :target => '/etc/motd' }} it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string/) + expect { catalogue }.to raise_error(Puppet::Error, /parameter 'content' expects a .*String.*/ ) end end end # content => @@ -86,29 +83,74 @@ describe 'concat::fragment', :type => :define do end end + context 'false' do + let(:title) { 'motd_header' } + let(:params) {{ :source => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /parameter 'source' expects a .*String.*Array.*/) + end + end + end # source => + + context 'order =>' do + ['', '42', 'a', 'z'].each do |order| + context '\'\'' do + it_behaves_like 'fragment', 'motd_header', { + :order => order, + :target => '/etc/motd', + } + end + end + context 'false' do let(:title) { 'motd_header' } - let(:params) {{ :source => false, :target => '/etc/motd' }} + let(:params) {{ :order => false, :target => '/etc/motd' }} it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /is not a string or an Array/) + expect { catalogue }.to raise_error(Puppet::Error, /Evaluation Error.*expects.*Boolean.*/) end end - end # source => + + context '123:456' do + let(:title) { 'motd_header' } + let(:params) {{ :order => '123:456', :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) + end + end + context '123/456' do + let(:title) { 'motd_header' } + let(:params) {{ :order => '123/456', :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) + end + end + context '123\n456' do + let(:title) { 'motd_header' } + let(:params) {{ :order => "123\n456", :target => '/etc/motd' }} + + it 'should fail' do + expect { catalogue }.to raise_error(Puppet::Error, /cannot contain/) + end + end + end # order => context 'more than one content source' do context 'source and content' do let(:title) { 'motd_header' } let(:params) do { - :target => '/etc/motd', + :target => '/etc/motd', :source => '/foo', :content => 'bar', } end it 'should fail' do - expect { catalogue }.to raise_error(Puppet::Error, /Can't use 'source' and 'content' at the same time/) + expect { catalogue }.to raise_error(Puppet::Error, /Can\'t use \'source\' and \'content\' at the same time/m) end end end # more than one content source