[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5

James Turnbull james at lovedthanlost.net
Wed Apr 8 21:48:11 UTC 2009


The following commit has been merged in the master branch:
commit 2a855510a3cca7d475c31495ccb502af606528dc
Author: Bryan Kearney <bkearney at redhat.com>
Date:   Fri Feb 13 08:21:36 2009 -0500

    Bug 1948: Add logic and testing for the command parsing logic

diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index fd47da3..8d4f6d5 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -52,7 +52,6 @@ Puppet::Type.type(:augeas).provide(:augeas) do
                 commands.concat(parse_commands(datum))
             end
         end
-
         return commands
     end
 
@@ -179,18 +178,20 @@ Puppet::Type.type(:augeas).provide(:augeas) do
                         debug("sending command '#{command}' with params #{cmd_array.inspect}")                    
                         aug.clear(cmd_array[0])
                     when "insert", "ins"
-                        if cmd_array.size < 3
+
+                        ext_array = cmd_array[1].split(" ") ;
+                        if cmd_array.size < 2 or ext_array.size < 2
                             fail("ins requires 3 parameters")
                         end
                         label = cmd_array[0]
-                        where = cmd_array[1]
-                        path = File.join(context, cmd_array[2]) 
+                        where = ext_array[0]
+                        path = File.join(context, ext_array[1]) 
                         case where
                             when "before": before = true
                             when "after": before = false
                             else fail("Invalid value '#{where}' for where param")
                         end
-                        debug("sending command '#{command}' with params #{[label, where, path]}") 
+                        debug("sending command '#{command}' with params #{[label, where, path].inspect()}") 
                         aug.insert(path, label, before)
                     else fail("Command '#{command}' is not supported")
                 end
diff --git a/spec/unit/provider/augeas/augeas.rb b/spec/unit/provider/augeas/augeas.rb
index 4bc1814..2def0d0 100644
--- a/spec/unit/provider/augeas/augeas.rb
+++ b/spec/unit/provider/augeas/augeas.rb
@@ -209,7 +209,7 @@ describe provider_class do
     
 
         it "should handle ins commands with before" do
-            command = [["ins", "Binks", "before", "/Jar/Jar"]]
+            command = [["ins", "Binks", "before /Jar/Jar"]]
             context = "/foo"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", true)
@@ -218,16 +218,25 @@ describe provider_class do
         end
 
         it "should handle ins commands with before" do
-            command = [["ins", "Binks", "after", "/Jar/Jar"]]
+            command = [["ins", "Binks", "after /Jar/Jar"]]
             context = "/foo"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)
             @augeas.expects(:save).returns(true)
             @provider.execute_changes.should == :executed
-        end             
+        end
+
+        it "should handle ins with no context" do
+            command = [["ins", "Binks", "after /Jar/Jar"]]
+            context = "" # this is the default
+            @resource.expects(:[]).times(2).returns(command).then.returns(context)
+            @augeas.expects(:insert).with("/Jar/Jar", "Binks", false)
+            @augeas.expects(:save).returns(true)
+            @provider.execute_changes.should == :executed
+        end         
         
         it "should handle multiple commands" do
-            command = [["ins", "Binks", "after", "/Jar/Jar"], ["clear", "/Jar/Jar"]]
+            command = [["ins", "Binks", "after /Jar/Jar"], ["clear", "/Jar/Jar"]]
             context = "/foo"
             @resource.expects(:[]).times(2).returns(command).then.returns(context)
             @augeas.expects(:insert).with("/foo/Jar/Jar", "Binks", false)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list