Sha256: cec7353f39b992feeaefe5606a0defa37555c8cb0f091fa947cede9bc344dc98

Contents?: true

Size: 1.4 KB

Versions: 35

Compression:

Stored size: 1.4 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

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

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 spec/unit/type/maillist_spec.rb
puppet-2.7.25 spec/unit/type/maillist_spec.rb
puppet-2.7.24 spec/unit/type/maillist_spec.rb
puppet-2.7.23 spec/unit/type/maillist_spec.rb
puppet-2.7.22 spec/unit/type/maillist_spec.rb
puppet-2.7.21 spec/unit/type/maillist_spec.rb
puppet-2.7.20 spec/unit/type/maillist_spec.rb
puppet-2.7.20.rc1 spec/unit/type/maillist_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/type/maillist_spec.rb
puppet-2.7.19 spec/unit/type/maillist_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/type/maillist_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/type/maillist_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/type/maillist_spec.rb
puppet-2.7.18 spec/unit/type/maillist_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/type/maillist_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/type/maillist_spec.rb
puppet-2.7.17 spec/unit/type/maillist_spec.rb
puppet-2.7.16 spec/unit/type/maillist_spec.rb
puppet-2.7.14 spec/unit/type/maillist_spec.rb
puppet-2.7.13 spec/unit/type/maillist_spec.rb