File: basic.rb

package info (click to toggle)
puppet 0.24.5-3%2Blenny2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,688 kB
  • ctags: 7,630
  • sloc: ruby: 97,655; sh: 721; lisp: 262; makefile: 167; xml: 122; python: 28
file content (85 lines) | stat: -rwxr-xr-x 2,171 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env ruby

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

require 'puppettest'

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

    def setup
        super
        @component = nil
        @configfile = nil
        @command = nil

        assert_nothing_raised() {
            @component = Puppet.type(:component).create(
                :name => "yaytest",
                :type => "testing"
            )
        }

        assert_nothing_raised() {
            @filepath = tempfile()
            @configfile = Puppet.type(:file).create(
                :path => @filepath,
                :ensure => "file",
                :checksum => "md5"
            )
        }
        assert_nothing_raised() {
            @command = Puppet.type(:exec).create(
                :title => "echo",
                :command => "echo yay",
                :path => ENV["PATH"]
            )
        }
        @config = mk_catalog(@component, @configfile, @command)
        @config.add_edge @component, @configfile
        @config.add_edge @component, @command
    end

    def teardown
        super
        stopservices
    end

    def test_values
        [:ensure, :checksum].each do |param|
            prop = @configfile.property(param)
            assert(prop, "got no property for %s" % param)
            assert(prop.value, "got no value for %s" % param)
        end
    end

    def test_name_calls
        [@command, @configfile].each { |obj|
            Puppet.debug "obj is %s" % obj
            assert_nothing_raised(){
                obj.name
            }
        }
    end

    def test_name_equality
        assert_equal(@filepath, @configfile.title)

        assert_equal("echo", @command.title)
    end

    def test_object_retrieval
        [@command, @configfile].each { |obj|
            assert_equal(obj.class[obj.name].object_id, obj.object_id,
                "%s did not match class version" % obj.ref)
        }
    end

    def test_paths
        [@configfile, @command, @component].each { |obj|
            assert_nothing_raised {
                assert_instance_of(String, obj.path)
            }
        }
    end
end