~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to test/types/basic.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env ruby
2
 
 
3
 
$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
4
 
 
5
 
require 'puppet'
6
 
require 'puppettest'
7
 
 
8
 
class TestBasic < Test::Unit::TestCase
9
 
        include PuppetTest
10
 
    # hmmm
11
 
    # this is complicated, because we store references to the created
12
 
    # objects in a central store
13
 
    def setup
14
 
        super
15
 
        @component = nil
16
 
        @configfile = nil
17
 
        @sleeper = nil
18
 
 
19
 
        assert_nothing_raised() {
20
 
            @component = Puppet.type(:component).create(
21
 
                :name => "yaytest",
22
 
                :type => "testing"
23
 
            )
24
 
        }
25
 
 
26
 
        assert_nothing_raised() {
27
 
            @filepath = tempfile()
28
 
            @@tmpfiles << @filepath
29
 
            @configfile = Puppet.type(:file).create(
30
 
                :path => @filepath,
31
 
                :ensure => "file",
32
 
                :checksum => "md5"
33
 
            )
34
 
        }
35
 
        assert_nothing_raised() {
36
 
            @sleeper = Puppet.type(:service).create(
37
 
                :name => "sleeper",
38
 
                :provider => "init",
39
 
                :path => exampledir("root/etc/init.d"),
40
 
                :hasstatus => true,
41
 
                :ensure => :running
42
 
            )
43
 
        }
44
 
        assert_nothing_raised() {
45
 
            @component.push(
46
 
                @configfile,
47
 
                @sleeper
48
 
            )
49
 
        }
50
 
        
51
 
        #puts "Component is %s, id %s" % [@component, @component.object_id]
52
 
        #puts "ConfigFile is %s, id %s" % [@configfile, @configfile.object_id]
53
 
    end
54
 
 
55
 
    def test_name_calls
56
 
        [@sleeper,@configfile].each { |obj|
57
 
            Puppet.debug "obj is %s" % obj
58
 
            assert_nothing_raised(){
59
 
                obj.name
60
 
            }
61
 
        }
62
 
    end
63
 
 
64
 
    def test_name_equality
65
 
        #puts "Component is %s, id %s" % [@component, @component.object_id]
66
 
        assert_equal(
67
 
            @filepath,
68
 
            @configfile.name
69
 
        )
70
 
 
71
 
        assert_equal(
72
 
            "sleeper",
73
 
            @sleeper.name
74
 
        )
75
 
    end
76
 
 
77
 
    def test_object_retrieval
78
 
        [@sleeper,@configfile].each { |obj|
79
 
            assert_equal(
80
 
                obj.class[obj.name].object_id,
81
 
                obj.object_id
82
 
            )
83
 
        }
84
 
    end
85
 
 
86
 
    def test_transaction
87
 
        transaction = nil
88
 
        assert_nothing_raised() {
89
 
            transaction = @component.evaluate
90
 
        }
91
 
        assert_nothing_raised() {
92
 
            transaction.evaluate
93
 
        }
94
 
        assert_nothing_raised() {
95
 
            @sleeper[:ensure] = :running
96
 
        }
97
 
        assert_nothing_raised() {
98
 
            transaction = @component.evaluate
99
 
        }
100
 
        assert_nothing_raised() {
101
 
            transaction.evaluate
102
 
        }
103
 
    end
104
 
 
105
 
    def test_paths
106
 
        [@configfile,@sleeper,@component].each { |obj|
107
 
            assert_nothing_raised {
108
 
                assert_instance_of(String, obj.path)
109
 
            }
110
 
        }
111
 
    end
112
 
end
113
 
 
114
 
# $Id: basic.rb 1793 2006-10-16 22:01:40Z luke $