File: features.rb

package info (click to toggle)
puppet 0.20.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,072 kB
  • ctags: 3,365
  • sloc: ruby: 47,009; sh: 496; lisp: 143; xml: 122; makefile: 67
file content (60 lines) | stat: -rwxr-xr-x 1,748 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env ruby
#
#  Created by Luke Kanies on 2006-11-07.
#  Copyright (c) 2006. All rights reserved.

$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/

require 'puppettest'
require 'puppet/feature'

class TestFeatures < Test::Unit::TestCase
	include PuppetTest
	
	def setup
	    super
	    libdir = tempfile()
	    @features = Puppet::Feature.new(libdir)
    end
	
	def test_new
	    assert_nothing_raised do
	        @features.add(:failer) do
	            raise ArgumentError, "nopes"
            end
        end
        
        assert(@features.respond_to?(:failer?), "Feature method did not get added")
        assert_nothing_raised("failure propagated outside of feature") do
            assert(! @features.failer?, "failure was considered true")
        end
        
        # Now make one that succeeds
        $succeeds = nil
        assert_nothing_raised("Failed to add normal feature") do
            @features.add(:succeeds) do
                $succeeds = true
            end
        end
        assert($succeeds, "Block was not called on initialization")
        
        assert(@features.respond_to?(:succeeds?), "Did not add succeeding feature")
        assert_nothing_raised("Failed to call succeeds") { assert(@features.succeeds?, "Feature was not true") }
    end
    
    def test_libs
        assert_nothing_raised do
            @features.add(:puppet, :libs => %w{puppet})
        end
        
        assert(@features.puppet?)
        
        assert_nothing_raised do
            @features.add(:missing, :libs => %w{puppet no/such/library/okay})
        end
        
        assert(! @features.missing?, "Missing lib was considered true")
    end
end

# $Id: features.rb 1835 2006-11-08 05:22:24Z luke $