From d77d6d4f9ec20c830c4e9ed34c8e2f1197386f4c Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 18 Oct 2006 03:43:48 +0000 Subject: Adding prefetch of providers to transactions. Nothing is using it yet. I wrote it for cron jobs, but it is too much work to fix this for cron jobs right now. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1806 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/other/transactions.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test') diff --git a/test/other/transactions.rb b/test/other/transactions.rb index dc654994e..3abc84f1b 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -52,6 +52,44 @@ class TestTransactions < Test::Unit::TestCase end end + def test_prefetch + # Create a type just for testing prefetch + name = :prefetchtesting + $prefetched = false + type = Puppet::Type.newtype(name) do + newparam(:name) {} + end + + # Now create a provider + type.provide(:prefetch) do + def self.prefetch + $prefetched = true + end + end + + # Now create an instance + inst = type.create :name => "yay" + + + # Create a transaction + trans = Puppet::Transaction.new([inst]) + + # Make sure prefetch works + assert_nothing_raised do + trans.prefetch + end + + assert_equal(true, $prefetched, "type prefetch was not called") + + # Now make sure it gets called from within evaluate() + $prefetched = false + assert_nothing_raised do + trans.evaluate + end + + assert_equal(true, $prefetched, "evaluate did not call prefetch") + end + def test_refreshes_generate_events path = tempfile() firstpath = tempfile() -- cgit