From e3abcd6b5330959016b43115a8bf1b1cef668d30 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 20 Jul 2015 16:18:52 -0400 Subject: Add package_manifest resource. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch converts the write_package_names function into a proper resource. Using the write_package_names only works if the function comes last in the puppet manifest. By making the same functionality a custom resource we allow for it to exist anywhere in the manifest and provide the same functionality. The new syntax would be: package_manifest{'/tmp/foo': ensure => present} Co-Authored-By: Martin Mágr Change-Id: If3e03b1983fed47082fac8ce63f975557dbc503c --- spec/unit/type/package_manifest_spec.rb | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/unit/type/package_manifest_spec.rb (limited to 'spec') diff --git a/spec/unit/type/package_manifest_spec.rb b/spec/unit/type/package_manifest_spec.rb new file mode 100644 index 0000000..096564c --- /dev/null +++ b/spec/unit/type/package_manifest_spec.rb @@ -0,0 +1,37 @@ + +require 'puppet' +require 'puppet/type/package_manifest' + +describe 'Puppet::Type.type(:package_manifest)' do + before :each do + @manifest = Puppet::Type.type(:package_manifest).new( + :path => '/tmp/test_package_manifest.txt', :ensure => 'present' + ) + end + + it 'should require a path' do + expect { + Puppet::Type.type(:package_manifest).new({}) + }.to raise_error Puppet::Error + end + + it 'should not require a value when ensure is absent' do + Puppet::Type.type(:package_manifest).new( + :path => '/tmp/test_package_manifest.txt', :ensure => :absent + ) + end + + it 'should accept valid ensure values' do + @manifest[:ensure] = :present + expect(@manifest[:ensure]).to eq(:present) + @manifest[:ensure] = :absent + expect(@manifest[:ensure]).to eq(:absent) + end + + it 'should not accept invalid ensure values' do + expect { + @manifest[:ensure] = :latest + }.to raise_error(Puppet::Error, /Invalid value/) + end + +end -- cgit 1.2.3-korg