summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2009-11-17 15:58:20 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-11-20 07:34:55 +1100
commitbe7ff82f92a14f4f572d738eeeb2c77437069c49 (patch)
treee45f0a28b61ddeeb5369b5786f82f48dc3e2f1e6 /spec
parent48beabadb6f234e6486cf32eebc389e8faba13f0 (diff)
Fix 2768 maillist resource is broken
Replace deprecated method call. This code was not tested before, so I've tried to capture what I think the method was trying to do. This version includes Luke's suggested change to better preserve the original behavior. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/type/maillist.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/type/maillist.rb b/spec/unit/type/maillist.rb
new file mode 100755
index 000000000..585336665
--- /dev/null
+++ b/spec/unit/type/maillist.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+maillist = Puppet::Type.type(:maillist)
+
+describe maillist do
+ before do
+ @provider_class = Puppet::Type.type(:maillist).provider(:mailman)
+
+ @provider = stub 'provider', :class => @provider_class, :clear => nil
+ @provider.stubs(:respond_to).with(:aliases).returns(true)
+
+ @provider_class.stubs(:new).returns(@provider)
+
+ Puppet::Type.type(:maillist).stubs(:defaultprovider).returns(@provider_class)
+
+ @maillist = Puppet::Type.type(:maillist).new( :name => 'test' )
+
+ @catalog = Puppet::Resource::Catalog.new
+ @maillist.catalog = @catalog
+ end
+
+ it "should generate aliases unless they already exist" do
+ # Mail List aliases are careful not to stomp on managed Mail Alias aliases
+
+ # test1 is an unmanaged alias from /etc/aliases
+ Puppet::Type.type(:mailalias).provider(:aliases).stubs(:target_object).returns( StringIO.new("test1: root\n") )
+
+ # test2 is a managed alias from the manifest
+ dupe = Puppet::Type.type(:mailalias).new( :name => 'test2' )
+ @catalog.add_resource dupe
+
+ @provider.stubs(:aliases).returns({"test1" => 'this will get included', "test2" => 'this will dropped', "test3" => 'this will get included'})
+
+ generated = @maillist.generate
+ generated.map{ |x| x.name }.sort.should == ['test1', 'test3']
+ generated.map{ |x| x.class }.should == [Puppet::Type::Mailalias, Puppet::Type::Mailalias]
+
+ end
+
+end