Sha256: eeb677c0fed1bd86ac0863674282cc892385bd71a52b552463b74fdfef623087

Contents?: true

Size: 1.52 KB

Versions: 19

Compression:

Stored size: 1.52 KB

Contents

#!/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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/type/maillist_spec.rb
puppet-2.6.17 spec/unit/type/maillist_spec.rb
puppet-2.6.16 spec/unit/type/maillist_spec.rb
puppet-2.6.15 spec/unit/type/maillist_spec.rb
puppet-2.6.14 spec/unit/type/maillist_spec.rb
puppet-2.6.13 spec/unit/type/maillist_spec.rb
puppet-2.6.12 spec/unit/type/maillist_spec.rb
puppet-2.6.11 spec/unit/type/maillist_spec.rb
puppet-2.6.10 spec/unit/type/maillist_spec.rb
puppet-2.6.9 spec/unit/type/maillist_spec.rb
puppet-2.6.8 spec/unit/type/maillist_spec.rb
puppet-2.6.7 spec/unit/type/maillist_spec.rb
puppet-2.6.6 spec/unit/type/maillist_spec.rb
puppet-2.6.5 spec/unit/type/maillist_spec.rb
puppet-2.6.4 spec/unit/type/maillist_spec.rb
puppet-2.6.3 spec/unit/type/maillist_spec.rb
puppet-2.6.2 spec/unit/type/maillist_spec.rb
puppet-2.6.1 spec/unit/type/maillist_spec.rb
puppet-2.6.0 spec/unit/type/maillist_spec.rb