[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:30:56 UTC 2010


The following commit has been merged in the upstream branch:
commit c30494f15ccaf1c1f15a9fde8b5a46a9adc4894a
Author: Luke Kanies <luke at reductivelabs.com>
Date:   Tue Jan 19 15:45:27 2010 -0800

    Renaming some methods in Transaction::Change
    
    Renaming 'go' to 'apply', which is a much more
    reasonable name.
    
    Also removing the 'backward' and 'forward' methods,
    since they're not actually used anywhere.  (Well,
    'forward' was used, but it just called 'go'.)
    
    Signed-off-by: Luke Kanies <luke at reductivelabs.com>

diff --git a/lib/puppet/transaction/change.rb b/lib/puppet/transaction/change.rb
index f8e2a7a..b3aac5a 100644
--- a/lib/puppet/transaction/change.rb
+++ b/lib/puppet/transaction/change.rb
@@ -6,15 +6,6 @@ require 'puppet/transaction/event'
 class Puppet::Transaction::Change
     attr_accessor :is, :should, :property, :proxy
 
-    # Switch the goals of the property, thus running the change in reverse.
-    def backward
-        @is, @should = @should, @is
-        @property.should = @should
-
-        @property.info "Reversing %s" % self
-        return self.go
-    end
-
     # Create our event object.
     def event
         result = property.event
@@ -32,9 +23,7 @@ class Puppet::Transaction::Change
         @changed = false
     end
 
-    # Perform the actual change.  This method can go either forward or
-    # backward, and produces an event.
-    def go
+    def apply
         return noop_event if noop?
 
         property.sync
@@ -56,10 +45,6 @@ class Puppet::Transaction::Change
         result
     end
 
-    def forward
-        return self.go
-    end
-
     # Is our property noop?  This is used for generating special events.
     def noop?
         return @property.noop
diff --git a/spec/unit/transaction/change.rb b/spec/unit/transaction/change.rb
index be1267b..1834147 100755
--- a/spec/unit/transaction/change.rb
+++ b/spec/unit/transaction/change.rb
@@ -95,7 +95,7 @@ describe Puppet::Transaction::Change do
 
                     @event.expects(:message=).with { |msg| msg.include?("should be") }
 
-                    @change.forward
+                    @change.apply
                 end
 
                 it "should produce a :noop event and return" do
@@ -103,14 +103,14 @@ describe Puppet::Transaction::Change do
 
                     @event.expects(:status=).with("noop")
 
-                    @change.forward.should == @event
+                    @change.apply.should == @event
                 end
             end
 
             it "should sync the property" do
                 @property.expects(:sync)
 
-                @change.forward
+                @change.apply
             end
 
             it "should return the default event if syncing the property returns nil" do
@@ -118,7 +118,7 @@ describe Puppet::Transaction::Change do
 
                 @change.expects(:event).with(nil).returns @event
 
-                @change.forward.should == @event
+                @change.apply.should == @event
             end
 
             it "should return the default event if syncing the property returns an empty array" do
@@ -126,7 +126,7 @@ describe Puppet::Transaction::Change do
 
                 @change.expects(:event).with(nil).returns @event
 
-                @change.forward.should == @event
+                @change.apply.should == @event
             end
 
             it "should log the change" do
@@ -134,16 +134,16 @@ describe Puppet::Transaction::Change do
 
                 @event.expects(:send_log)
 
-                @change.forward
+                @change.apply
             end
 
             it "should set the event's message to the change log" do
                 @property.expects(:change_to_s).returns "my change"
-                @change.forward.message.should == "my change"
+                @change.apply.message.should == "my change"
             end
 
             it "should set the event's status to 'success'" do
-                @change.forward.status.should == "success"
+                @change.apply.status.should == "success"
             end
 
             describe "and the change fails" do
@@ -151,46 +151,15 @@ describe Puppet::Transaction::Change do
 
                 it "should catch the exception and log the err" do
                     @event.expects(:send_log)
-                    lambda { @change.forward }.should_not raise_error
+                    lambda { @change.apply }.should_not raise_error
                 end
 
                 it "should mark the event status as 'failure'" do
-                    @change.forward.status.should == "failure"
+                    @change.apply.status.should == "failure"
                 end
 
                 it "should set the event log to a failure log" do
-                    @change.forward.message.should be_include("failed")
-                end
-            end
-
-            describe "backward" do
-                before do
-                    @property = stub 'property'
-                    @property.stub_everything
-                    @property.stubs(:should).returns "shouldval"
-                    @change = Change.new(@property, "value")
-                    @change.stubs :go
-                end
-
-                it "should swap the 'is' and 'should' values" do
-                    @change.backward
-                    @change.is.should == "shouldval"
-                    @change.should.should == "value"
-                end
-
-                it "should set the 'should' value on the property to the previous 'is' value" do
-                    @property.expects(:should=).with "value"
-                    @change.backward
-                end
-
-                it "should log that it's reversing the change" do
-                    @property.expects(:info)
-                    @change.backward
-                end
-
-                it "should execute and return the resulting event" do
-                    @change.expects(:go).returns :myevent
-                    @change.backward.should == :myevent
+                    @change.apply.message.should be_include("failed")
                 end
             end
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list