summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-07-05 10:21:36 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-07-05 10:21:36 +1000
commit81be1c5c3f85f514505e99fab5b8a2b2ae6fbec8 (patch)
tree192dd042cd69942d2ac803fce86e1b97eb0b3390 /test
parent083f4ca7862fbde5cb6fb5562be10f13b66d9250 (diff)
parent9d69b3fd12f90ddead7b6a3392395fbe4e901d9b (diff)
downloadpuppet-81be1c5c3f85f514505e99fab5b8a2b2ae6fbec8.tar.gz
puppet-81be1c5c3f85f514505e99fab5b8a2b2ae6fbec8.tar.xz
puppet-81be1c5c3f85f514505e99fab5b8a2b2ae6fbec8.zip
Merge branch 'refactor/0.24.x/transaction_changes' of git://github.com/lak/puppet into 0.24.x
Diffstat (limited to 'test')
-rw-r--r--test/lib/puppettest/support/utils.rb2
-rwxr-xr-xtest/other/propertychange.rb140
-rwxr-xr-xtest/other/transactions.rb11
3 files changed, 6 insertions, 147 deletions
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index cb4a6924c..654531cfc 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -88,7 +88,7 @@ module PuppetTest::Support::Utils
newevents = nil
assert_nothing_raised("Transaction %s %s failed" % [type, msg]) {
newevents = trans.send(method).reject { |e| e.nil? }.collect { |e|
- e.event
+ e.name
}
}
diff --git a/test/other/propertychange.rb b/test/other/propertychange.rb
deleted file mode 100755
index eaa4f4082..000000000
--- a/test/other/propertychange.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/usr/bin/env ruby
-#
-# Created by Luke A. Kanies on 2006-12-21.
-# Copyright (c) 2006. All rights reserved.
-
-require File.dirname(__FILE__) + '/../lib/puppettest'
-
-require 'puppettest'
-
-class TestPropertyChange < Test::Unit::TestCase
- include PuppetTest
- class FakeProperty < Puppet::Property
- attr_accessor :is, :should, :resource
- attr_reader :noop
- def change_to_s(currentvalue, newvalue)
- "fake change"
- end
- def insync?(is)
- is == @should
- end
- def log(msg)
- Puppet::Util::Log.create(
- :level => :info,
- :source => self,
- :message => msg
- )
- end
- def noop
- if defined? @noop
- @noop
- else
- false
- end
- end
- def path
- "fakechange"
- end
- def should_to_s(newvalue)
- newvalue.to_s
- end
- def sync
- if insync?(@is)
- return nil
- else
- @is = @should
- return :fake_change
- end
- end
- def to_s
- path
- end
- end
-
- def mkchange
- property = FakeProperty.new :resource => "fakeparent"
- property.is = :start
- property.should = :finish
- property.resource = :parent
- change = nil
- assert_nothing_raised do
- change = Puppet::PropertyChange.new(property, :start)
- end
- change.transaction = :trans
-
- assert_equal(:start, change.is, "@is did not get copied")
- assert_equal(:finish, change.should, "@should did not get copied")
- assert_equal(%w{fakechange change}, change.path, "path did not get set correctly")
-
- assert(! change.changed?, "change defaulted to already changed")
-
- return change
- end
-
- def test_go
- change = mkchange
-
- coll = logcollector()
-
- events = nil
- # First make sure we get an immediate return
- assert_nothing_raised do
- events = change.go
- end
- assert_instance_of(Array, events, "events were not returned in an array")
- assert_instance_of(Puppet::Event, events[0], "event array did not contain events")
-
- event = events.shift
- {:event => :fake_change, :transaction => :trans, :source => :parent}.each do |method, val|
- assert_equal(val, event.send(method), "Event did not set %s correctly" % method)
- end
-
- # Disabled, because it fails when running the whole suite at once.
- #assert(coll.detect { |l| l.message == "fake change" }, "Did not log change")
- assert_equal(change.property.is, change.property.should, "did not call sync method")
-
- # Now make sure that proxy sources can be set.
- assert_nothing_raised do
- change.proxy = :other
- end
- # Reset, so we change again
- change.property.is = :start
- change.is = :start
- assert_nothing_raised do
- events = change.go
- end
-
- assert_instance_of(Array, events, "events were not returned in an array")
- assert_instance_of(Puppet::Event, events[0], "event array did not contain events")
-
- event = events.shift
- {:event => :fake_change, :transaction => :trans, :source => :other}.each do |method, val|
- assert_equal(val, event.send(method), "Event did not set %s correctly" % method)
- end
-
- #assert(coll.detect { |l| l.message == "fake change" }, "Did not log change")
- assert_equal(change.property.is, change.property.should, "did not call sync method")
- end
-
- # Related to #542. Make sure changes in noop mode produce the :noop event.
- def test_noop_event
- change = mkchange
-
- assert(! change.skip?, "Change is already being skipped")
-
- Puppet[:noop] = true
-
- change.property.noop = true
- assert(change.noop, "did not set noop")
- assert(change.skip?, "setting noop did not mark change for skipping")
-
- event = nil
- assert_nothing_raised("Could not generate noop event") do
- event = change.forward
- end
-
- assert_equal(1, event.length, "got wrong number of events")
- assert_equal(:noop, event[0].event, "did not generate noop mode when in noop")
- end
-end
-
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index a517ac731..7f42bb6f4 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -796,7 +796,7 @@ class TestTransactions < Test::Unit::TestCase
def test_proxy_resources
type = mkreducer do
def evaluate
- return Puppet::PropertyChange.new(Fakeprop.new(
+ return Puppet::Transaction::Change.new(Fakeprop.new(
:path => :path, :is => :is, :should => :should, :name => self.name, :resource => "a parent"), :is)
end
end
@@ -815,7 +815,7 @@ class TestTransactions < Test::Unit::TestCase
assert(changes.length > 0, "did not get any changes")
changes.each do |change|
- assert_equal(resource, change.source, "change did not get proxy set correctly")
+ assert_equal(resource, change.resource, "change did not get proxy set correctly")
end
end
@@ -905,10 +905,9 @@ class TestTransactions < Test::Unit::TestCase
assert(result, "c did not trigger anything")
assert_instance_of(Array, result)
event = result.shift
- assert_instance_of(Puppet::Event, event)
- assert_equal(:triggered, event.event, "event was not set correctly")
+ assert_instance_of(Puppet::Transaction::Event, event)
+ assert_equal(:triggered, event.name, "event was not set correctly")
assert_equal(c, event.source, "source was not set correctly")
- assert_equal(trans, event.transaction, "transaction was not set correctly")
assert(trans.triggered?(c, :refresh),
"Transaction did not store the trigger")
@@ -995,7 +994,7 @@ class TestTransactions < Test::Unit::TestCase
newparam(:name) {}
newproperty(:testing) do
def sync
- self.is = self.should
+ # noop
:ran_testing
end
end