3 require File.dirname(__FILE__) + '/../lib/puppettest'
8 # Test the different features of the main puppet module
9 class TestPuppetModule < Test::Unit::TestCase
11 include SignalObserver
14 Class.new(Puppet::Network::Client) do
19 Puppet.info "fake client has run"
31 FileTest.exists?(@file)
35 File.open(@file, "w") do |f| f.puts "" end
44 # Make sure that services get correctly started and stopped
45 def test_servicehandling
47 testclass = mktestclass()
49 obj = testclass.new(file)
51 assert_nothing_raised {
52 Puppet.newservice(obj)
55 assert_nothing_raised {
62 assert(obj.started?, "Object was not started")
64 assert_nothing_raised {
65 Puppet.shutdown(false)
70 assert(!obj.started?, "Object is still running")
79 newpath = oldpath + ":" + "/something/else"
80 assert_nothing_raised do
81 Puppet[:path] = newpath
84 assert_equal(newpath, ENV["PATH"])
91 unless oldlibs.include?(dir)
101 # Make sure setting the libdir gets the dir added to $:
102 assert_nothing_raised do
103 Puppet[:libdir] = one
106 assert($:.include?(one), "libdir was not added")
108 # Now change it, make sure it gets added and the old one gets
110 assert_nothing_raised do
111 Puppet[:libdir] = two
114 assert($:.include?(two), "libdir was not added")
115 assert(! $:.include?(one), "old libdir was not removed")
119 # Make sure it defaults to $0 without the rb
120 should = $0.gsub(/.+#{File::SEPARATOR}/,'').sub(/\.rb$/, '')
122 assert_equal(should, Puppet[:name], "default name was not right")
124 assert_nothing_raised("Could not reset name") do
125 Puppet[:name] = "puppetca"
128 assert_equal("puppetca", Puppet[:name], "name reset did not take")