def apply(resource, logs)
      logs.clear
      Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(logs))
      Puppet::Util::Log.level = 'debug'

      confdir = Dir.mktmpdir
      oldconfdir = Puppet[:confdir]
      Puppet[:confdir] = confdir

      [:require, :before, :notify, :subscribe].each { |p| resource.delete p }
      catalog = Puppet::Resource::Catalog.new
      catalog.add_resource resource
      catalog = catalog.to_ral if resource.is_a? Puppet::Resource
      txn = catalog.apply

      Puppet::Util::Log.close_all
      txn
    ensure
      if confdir
        Puppet[:confdir] = oldconfdir
        FileUtils.rm_rf(confdir)
      end
    end
def apply(resource, logs)
      logs.clear
      Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(logs))
      Puppet::Util::Log.level = 'debug'

      confdir = Dir.mktmpdir
      oldconfdir = Puppet[:confdir]
      Puppet[:confdir] = confdir

      [:require, :before, :notify, :subscribe].each { |p| resource.delete p }
      catalog = Puppet::Resource::Catalog.new
      catalog.add_resource resource
      catalog = catalog.to_ral if resource.is_a? Puppet::Resource
      txn = catalog.apply

      Puppet::Util::Log.close_all
      txn
    ensure
      if confdir
        Puppet[:confdir] = oldconfdir
        FileUtils.rm_rf(confdir)
      end
    end
Runs a particular resource via a catalog and stores logs in the caller's
 supplied array