From 4032a270d90ef93b39ed1df17ebe1040a11128b9 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Apr 2008 00:20:26 -0500 Subject: Fixing the integration tests related to the destroy fix. Yay. --- spec/integration/node.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/integration/node.rb') diff --git a/spec/integration/node.rb b/spec/integration/node.rb index 631d4403e..d9c2618c9 100755 --- a/spec/integration/node.rb +++ b/spec/integration/node.rb @@ -34,7 +34,7 @@ describe Puppet::Node, " when using the memory terminus" do it "should be able to remove previously saved nodes" do @node.save - Puppet::Node.destroy(@node) + Puppet::Node.destroy(@node.name) Puppet::Node.find(@name).should be_nil end -- cgit From 7774d9c443f19d44a1e2dab459fc4bfb94e75244 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Apr 2008 21:21:59 -0500 Subject: Ported the rest of the indirection terminuses over to expecting requests instead of having a random interface. --- spec/integration/node.rb | 104 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 28 deletions(-) (limited to 'spec/integration/node.rb') diff --git a/spec/integration/node.rb b/spec/integration/node.rb index d9c2618c9..b0375e743 100755 --- a/spec/integration/node.rb +++ b/spec/integration/node.rb @@ -7,38 +7,86 @@ require File.dirname(__FILE__) + '/../spec_helper' require 'puppet/node' -describe Puppet::Node, " when using the memory terminus" do - before do - @name = "me" - @old_terminus = Puppet::Node.indirection.terminus_class - @terminus = Puppet::Node.indirection.terminus(:memory) - Puppet::Node.indirection.stubs(:terminus).returns @terminus - @node = Puppet::Node.new(@name) - end +describe Puppet::Node do + describe "when delegating indirection calls" do + before do + @name = "me" + @node = Puppet::Node.new(@name) + end - it "should find no nodes by default" do - Puppet::Node.find(@name).should be_nil - end + it "should be able to use the exec terminus" do + Puppet::Node.indirection.stubs(:terminus_class).returns :exec - it "should be able to find nodes that were previously saved" do - @node.save - Puppet::Node.find(@name).should equal(@node) - end + # Load now so we can stub + terminus = Puppet::Node.indirection.terminus(:exec) - it "should replace existing saved nodes when a new node with the same name is saved" do - @node.save - two = Puppet::Node.new(@name) - two.save - Puppet::Node.find(@name).should equal(two) - end + terminus.expects(:query).with(@name).returns "myresults" + terminus.expects(:translate).with(@name, "myresults").returns "translated_results" + terminus.expects(:create_node).with(@name, "translated_results").returns @node - it "should be able to remove previously saved nodes" do - @node.save - Puppet::Node.destroy(@node.name) - Puppet::Node.find(@name).should be_nil - end + Puppet::Node.find(@name).should equal(@node) + end + + it "should be able to use the yaml terminus" do + Puppet::Node.indirection.stubs(:terminus_class).returns :yaml + + # Load now, before we stub the exists? method. + Puppet::Node.indirection.terminus(:yaml) + + file = File.join(Puppet[:yamldir], "node", "me.yaml") + FileTest.expects(:exist?).with(file).returns false + Puppet::Node.find(@name).should be_nil + end + + it "should have an ldap terminus" do + Puppet::Node.indirection.terminus(:ldap).should_not be_nil + end + + it "should be able to use the plain terminus" do + Puppet::Node.indirection.stubs(:terminus_class).returns :plain + + # Load now, before we stub the exists? method. + Puppet::Node.indirection.terminus(:plain) + + Puppet::Node.expects(:new).with(@name).returns @node + + Puppet::Node.find(@name).should equal(@node) + end + + describe "and using the memory terminus" do + before do + @name = "me" + @old_terminus = Puppet::Node.indirection.terminus_class + @terminus = Puppet::Node.indirection.terminus(:memory) + Puppet::Node.indirection.stubs(:terminus).returns @terminus + @node = Puppet::Node.new(@name) + end + + it "should find no nodes by default" do + Puppet::Node.find(@name).should be_nil + end + + it "should be able to find nodes that were previously saved" do + @node.save + Puppet::Node.find(@name).should equal(@node) + end + + it "should replace existing saved nodes when a new node with the same name is saved" do + @node.save + two = Puppet::Node.new(@name) + two.save + Puppet::Node.find(@name).should equal(two) + end + + it "should be able to remove previously saved nodes" do + @node.save + Puppet::Node.destroy(@node.name) + Puppet::Node.find(@name).should be_nil + end - it "should fail when asked to destroy a node that does not exist" do - proc { Puppet::Node.destroy(@node) }.should raise_error(ArgumentError) + it "should fail when asked to destroy a node that does not exist" do + proc { Puppet::Node.destroy(@node) }.should raise_error(ArgumentError) + end + end end end -- cgit