Sha256: 269ac709edac34afee137ff7da1e4695b44d271dc2633f6a2f9e0239abdda75e

Contents?: true

Size: 1.7 KB

Versions: 20

Compression:

Stored size: 1.7 KB

Contents

#!/usr/bin/env ruby

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

require 'puppet'
require 'puppettest'

# Test the different features of the main puppet module
class TestPuppetModule < Test::Unit::TestCase
  include PuppetTest
  include SignalObserver

  def mkfakeclient
    Class.new(Puppet::Network::Client) do
      def initialize
      end

      def runnow
        Puppet.info "fake client has run"
      end
    end
  end

  def mktestclass
    Class.new do
      def initialize(file)
        @file = file
      end

      def started?
        FileTest.exists?(@file)
      end

      def start
        File.open(@file, "w") do |f| f.puts "" end
      end

      def shutdown
        File.unlink(@file)
      end
    end
  end

  def test_path
    oldpath = ENV["PATH"]
    cleanup do
      ENV["PATH"] = oldpath
    end
    newpath = oldpath + ":/something/else"
    assert_nothing_raised do
      Puppet[:path] = newpath
    end

    assert_equal(newpath, ENV["PATH"])
  end

  def test_libdir
    oldlibs = $LOAD_PATH.dup
    cleanup do
      $LOAD_PATH.each do |dir|
        $LOAD_PATH.delete(dir) unless oldlibs.include?(dir)
      end
    end
    one = tempfile
    two = tempfile
    Dir.mkdir(one)
    Dir.mkdir(two)

    # Make sure setting the libdir gets the dir added to $LOAD_PATH
    assert_nothing_raised do
      Puppet[:libdir] = one
    end

    assert($LOAD_PATH.include?(one), "libdir was not added")

    # Now change it, make sure it gets added and the old one gets
    # removed
    assert_nothing_raised do
      Puppet[:libdir] = two
    end

    assert($LOAD_PATH.include?(two), "libdir was not added")
    assert(! $LOAD_PATH.include?(one), "old libdir was not removed")
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
puppet-2.7.13 test/other/puppet.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
puppet-2.7.12 test/other/puppet.rb
puppet-2.7.11 test/other/puppet.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/other/puppet.rb
puppet-2.7.9 test/other/puppet.rb
puppet-2.7.8 test/other/puppet.rb
puppet-2.7.6 test/other/puppet.rb
puppet-2.7.5 test/other/puppet.rb
puppet-2.7.4 test/other/puppet.rb
puppet-2.7.3 test/other/puppet.rb
puppet-2.7.1 test/other/puppet.rb