File: mailalias.rb

package info (click to toggle)
puppet 2.6.2-5%2Bsqueeze10
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 13,728 kB
  • ctags: 8,726
  • sloc: ruby: 110,196; sh: 937; lisp: 263; xml: 122; sql: 103; makefile: 90; python: 84
file content (45 lines) | stat: -rwxr-xr-x 1,181 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../lib/puppettest'

require 'puppettest'
require 'mocha'

class TestMailAlias < Test::Unit::TestCase
  include PuppetTest

  def setup
    super
    @type = Puppet::Type.type(:mailalias)

    @provider = @type.defaultprovider

    # Make sure they are using the parsed provider
    unless @provider.name == :aliases
      @type.defaultprovider = @type.provider(:aliases)
    end

    cleanup do @type.defaultprovider = nil end

    if @provider.respond_to?(:default_target=)
      @default_file = @provider.default_target
      cleanup do
        @provider.default_target = @default_file
      end
      @target = tempfile
      @provider.default_target = @target
    end
  end

  # This isn't much of a test, but then, it's not much of a type.
  def test_recipient_arrays
    resource = @type.new(:name => "luke", :recipient => "yay", :target => tempfile)
    values = resource.retrieve_resource
    assert_equal(:absent, values[:recipient])
    resource.property(:recipient).expects(:set).with(%w{yay})
    assert_nothing_raised("Could not sync mailalias") do
      resource.property(:recipient).sync
    end
  end
end