summaryrefslogtreecommitdiffstats
path: root/test/network/handler/node.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-08-15 17:18:43 -0500
committerLuke Kanies <luke@madstop.com>2007-08-15 17:18:43 -0500
commit1527f4a615f9c429e90becd90f9ed1e8c1e83249 (patch)
tree87656fd11245e4e00605eac7cb20fe8cd8367338 /test/network/handler/node.rb
parenta9539548d957304a03aa8bdc61c06793228f57c0 (diff)
downloadpuppet-1527f4a615f9c429e90becd90f9ed1e8c1e83249.tar.gz
puppet-1527f4a615f9c429e90becd90f9ed1e8c1e83249.tar.xz
puppet-1527f4a615f9c429e90becd90f9ed1e8c1e83249.zip
Adding node caching, so that node sources are not spammed during file serving and such
Diffstat (limited to 'test/network/handler/node.rb')
-rwxr-xr-xtest/network/handler/node.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/network/handler/node.rb b/test/network/handler/node.rb
index 9902c2dd1..745c7470e 100755
--- a/test/network/handler/node.rb
+++ b/test/network/handler/node.rb
@@ -66,7 +66,7 @@ module NodeTesting
end
end
-class TestNodeInterface < Test::Unit::TestCase
+class TestNodeHandler < Test::Unit::TestCase
include NodeTesting
def setup
@@ -318,6 +318,28 @@ class TestNodeInterface < Test::Unit::TestCase
end
assert_equal(%w{yay foo}, result, "Did not get classes back")
end
+
+ # We reuse the filetimeout for the node caching timeout.
+ def test_node_caching
+ handler = Node.new
+
+ node = Object.new
+ node.metaclass.instance_eval do
+ attr_accessor :time, :name
+ end
+ node.time = Time.now
+ node.name = "yay"
+
+ # Make sure caching works normally
+ assert_nothing_raised("Could not cache node") do
+ handler.send(:cache, node)
+ end
+ assert_equal(node.object_id, handler.send(:cached?, "yay").object_id, "Did not get node back from the cache")
+
+ # Now set the node's time to be a long time ago
+ node.time = Time.now - 50000
+ assert(! handler.send(:cached?, "yay"), "Timed-out node was returned from cache")
+ end
end
class TestSimpleNode < Test::Unit::TestCase
@@ -332,6 +354,7 @@ class TestSimpleNode < Test::Unit::TestCase
assert_equal("testing", node.name, "Did not set name correctly")
assert_equal({}, node.parameters, "Node parameters did not default correctly")
assert_equal([], node.classes, "Node classes did not default correctly")
+ assert_instance_of(Time, node.time, "Did not set the creation time")
# Now test it with values for both
params = {"a" => "b"}