diff options
author | Josh Cooper <josh@puppet.com> | 2018-04-26 11:41:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-26 11:41:34 -0700 |
commit | 81d2cf81cd02c09f53774c1b95ae2de474b28b80 (patch) | |
tree | 4997f732281a7e0cb5ff33a745663cc5cffed741 /spec/unit | |
parent | 7c51be1c0d8ace7cb679f16ee4d8e3697ea95ae8 (diff) | |
parent | beb0aa2b549ed4b6f90d82a864a443e35c102b38 (diff) | |
download | puppet-mailalias_core-81d2cf81cd02c09f53774c1b95ae2de474b28b80.tar.gz puppet-mailalias_core-81d2cf81cd02c09f53774c1b95ae2de474b28b80.tar.bz2 |
Merge pull request #1 from melissa/maint/master/initial-commits
Maint/master/initial commits
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/type/mailalias_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/unit/type/mailalias_spec.rb b/spec/unit/type/mailalias_spec.rb new file mode 100644 index 0000000..1fb195e --- /dev/null +++ b/spec/unit/type/mailalias_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' + +describe Puppet::Type.type(:mailalias) do + include PuppetSpec::Files + + let :tmpfile_path do + tmpfile('afile') + end + + let :target do + tmpfile('mailalias') + end + + let :recipient_resource do + described_class.new(name: 'luke', recipient: 'yay', target: target) + end + + let :file_resource do + described_class.new(name: 'lukefile', file: tmpfile_path, target: target) + end + + it 'is initially absent as a recipient' do + expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent) + end + + it 'is initially absent as an included file' do + expect(file_resource.retrieve_resource[:file]).to eq(:absent) + end + + it 'tries and set the recipient when it does the sync' do + expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent) + recipient_resource.property(:recipient).expects(:set).with(['yay']) + recipient_resource.property(:recipient).sync + end + + it 'tries and set the included file when it does the sync' do + expect(file_resource.retrieve_resource[:file]).to eq(:absent) + file_resource.property(:file).expects(:set).with(tmpfile_path) + file_resource.property(:file).sync + end + + it 'fails when file is not an absolute path' do + expect { + Puppet::Type.type(:mailalias).new(name: 'x', file: 'afile') + }.to raise_error Puppet::Error, %r{File paths must be fully qualified} + end + + it 'fails when both file and recipient are specified' do + expect { + Puppet::Type.type(:mailalias).new(name: 'x', file: tmpfile_path, + recipient: 'foo@example.com') + }.to raise_error Puppet::Error, %r{cannot specify both a recipient and a file} + end +end |