summaryrefslogtreecommitdiffstats
path: root/test/network/handler
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-12 15:32:25 -0500
committerLuke Kanies <luke@madstop.com>2007-09-12 15:32:25 -0500
commita6fe70054f4fb3efe4d558ffdd244917ca1c6f9c (patch)
tree6b8dbf7f3f2779254174b0829412a5365ad6ebed /test/network/handler
parent1459c507ddccff2a2a6fbadd4c880c023b5e9893 (diff)
downloadpuppet-a6fe70054f4fb3efe4d558ffdd244917ca1c6f9c.tar.gz
puppet-a6fe70054f4fb3efe4d558ffdd244917ca1c6f9c.tar.xz
puppet-a6fe70054f4fb3efe4d558ffdd244917ca1c6f9c.zip
Another intermediate commit. The node and fact classes are now functional and are used instead of the network handlers, which have been removed. There are some failing tests as a result, but I want to get this code committed before I massage the rest of the system to make it work again.
Diffstat (limited to 'test/network/handler')
-rwxr-xr-xtest/network/handler/configuration.rb4
-rwxr-xr-xtest/network/handler/facts.rb112
-rwxr-xr-xtest/network/handler/master.rb5
3 files changed, 7 insertions, 114 deletions
diff --git a/test/network/handler/configuration.rb b/test/network/handler/configuration.rb
index 0964a4c5e..29a393769 100755
--- a/test/network/handler/configuration.rb
+++ b/test/network/handler/configuration.rb
@@ -63,14 +63,14 @@ class TestHandlerConfiguration < Test::Unit::TestCase
fakenode = Object.new
# Set the server facts to something
config.instance_variable_set("@server_facts", :facts)
- fakenode.expects(:fact_merge).with(:facts)
+ fakenode.expects(:merge).with(:facts)
config.send(:add_node_data, fakenode)
# Now try it with classes.
config.instance_variable_set("@options", {:Classes => %w{a b}})
list = []
fakenode = Object.new
- fakenode.expects(:fact_merge).with(:facts)
+ fakenode.expects(:merge).with(:facts)
fakenode.expects(:classes).returns(list).times(2)
config.send(:add_node_data, fakenode)
assert_equal(%w{a b}, list, "Did not add classes to node")
diff --git a/test/network/handler/facts.rb b/test/network/handler/facts.rb
deleted file mode 100755
index 03327b8c4..000000000
--- a/test/network/handler/facts.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
-
-require 'puppettest'
-require 'mocha'
-require 'puppet/network/handler/facts'
-
-class TestFactsHandler < Test::Unit::TestCase
- include PuppetTest::ServerTest
-
- def setup
- super
-
- @class = Puppet::Network::Handler.handler(:facts)
-
- @@client_facts = {}
-
- unless Puppet::Util::FactStore.store(:testing)
- Puppet::Util::FactStore.newstore(:testing) do
- def get(node)
- @@client_facts[node]
- end
-
- def set(node, facts)
- @@client_facts[node] = facts
- end
- end
- end
-
- Puppet[:factstore] = :testing
-
- @handler = @class.new
-
- @facts = {:a => :b, :c => :d}
- @name = "foo"
-
- @backend = @handler.instance_variable_get("@backend")
- end
-
- def teardown
- @@client_facts.clear
- end
-
- def test_strip_internal
- @facts[:_puppet_one] = "yay"
- @facts[:_puppet_two] = "boo"
- @facts[:_puppetthree] = "foo"
-
- newfacts = nil
- assert_nothing_raised("Could not call strip_internal") do
- newfacts = @handler.send(:strip_internal, @facts)
- end
-
- [:_puppet_one, :_puppet_two, :_puppetthree].each do |name|
- assert(@facts.include?(name), "%s was removed in strip_internal from original hash" % name)
- end
- [:_puppet_one, :_puppet_two].each do |name|
- assert(! newfacts.include?(name), "%s was not removed in strip_internal" % name)
- end
- assert_equal("foo", newfacts[:_puppetthree], "_puppetthree was removed in strip_internal")
- end
-
- def test_add_internal
- newfacts = nil
- assert_nothing_raised("Could not call strip_internal") do
- newfacts = @handler.send(:add_internal, @facts)
- end
-
- assert_instance_of(Time, newfacts[:_puppet_timestamp], "Did not set timestamp in add_internal")
- assert(! @facts.include?(:_puppet_timestamp), "Modified original hash in add_internal")
- end
-
- def test_set
- newfacts = @facts.dup
- newfacts[:_puppet_timestamp] = Time.now
- @handler.expects(:add_internal).with(@facts).returns(newfacts)
- @backend.expects(:set).with(@name, newfacts).returns(nil)
-
- assert_nothing_raised("Could not set facts") do
- assert_nil(@handler.set(@name, @facts), "handler.set did not return nil")
- end
- end
-
- def test_get
- prefacts = @facts.dup
- prefacts[:_puppet_timestamp] = Time.now
- @@client_facts[@name] = prefacts
- @handler.expects(:strip_internal).with(prefacts).returns(@facts)
- @backend.expects(:get).with(@name).returns(prefacts)
-
- assert_nothing_raised("Could not retrieve facts") do
- assert_equal(@facts, @handler.get(@name), "did not get correct answer from handler.get")
- end
-
- @handler = @class.new
- assert_nothing_raised("Failed to call 'get' with no stored facts") do
- @handler.get("nosuchname")
- end
- end
-
- def test_store_date
- time = Time.now
- @facts[:_puppet_timestamp] = time
-
- @handler.expects(:get).with(@name).returns(@facts)
-
- assert_equal(time.to_i, @handler.store_date(@name), "Did not retrieve timestamp correctly")
- end
-end
-
-# $Id$
diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb
index a976726ef..9749c7bdf 100755
--- a/test/network/handler/master.rb
+++ b/test/network/handler/master.rb
@@ -8,6 +8,11 @@ require 'puppet/network/handler/master'
class TestMaster < Test::Unit::TestCase
include PuppetTest::ServerTest
+ def teardown
+ super
+ Puppet::Indirector::Indirection.clear_cache
+ end
+
def test_defaultmanifest
textfiles { |file|
Puppet[:manifest] = file