Sha256: 482a9a25d2d2e009e9a0902c334cad3f4e5f370e4c523d29546de6e9a1aeab96

Contents?: true

Size: 1.56 KB

Versions: 19

Compression:

Stored size: 1.56 KB

Contents

#!/usr/bin/env ruby
#
#  Created by Luke Kanies on 2008-4-8.
#  Copyright (c) 2008. All rights reserved.

require File.dirname(__FILE__) + '/../../spec_helper'

describe Puppet::Node::Facts do
  describe "when using the indirector" do
    after { Puppet::Util::Cacher.expire }

    it "should expire any cached node instances when it is saved" do
      Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml

      Puppet::Node::Facts.indirection.terminus(:yaml).should equal(Puppet::Node::Facts.indirection.terminus(:yaml))
      terminus = Puppet::Node::Facts.indirection.terminus(:yaml)
      terminus.stubs :save

      Puppet::Node.expects(:expire).with("me")

      facts = Puppet::Node::Facts.new("me")
      facts.save
    end

    it "should be able to delegate to the :yaml terminus" do
      Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml

      # Load now, before we stub the exists? method.
      terminus = Puppet::Node::Facts.indirection.terminus(:yaml)

      terminus.expects(:path).with("me").returns "/my/yaml/file"
      FileTest.expects(:exist?).with("/my/yaml/file").returns false

      Puppet::Node::Facts.find("me").should be_nil
    end

    it "should be able to delegate to the :facter terminus" do
      Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :facter

      Facter.expects(:to_hash).returns "facter_hash"
      facts = Puppet::Node::Facts.new("me")
      Puppet::Node::Facts.expects(:new).with("me", "facter_hash").returns facts

      Puppet::Node::Facts.find("me").should equal(facts)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/integration/node/facts_spec.rb
puppet-2.6.17 spec/integration/node/facts_spec.rb
puppet-2.6.16 spec/integration/node/facts_spec.rb
puppet-2.6.15 spec/integration/node/facts_spec.rb
puppet-2.6.14 spec/integration/node/facts_spec.rb
puppet-2.6.13 spec/integration/node/facts_spec.rb
puppet-2.6.12 spec/integration/node/facts_spec.rb
puppet-2.6.11 spec/integration/node/facts_spec.rb
puppet-2.6.10 spec/integration/node/facts_spec.rb
puppet-2.6.9 spec/integration/node/facts_spec.rb
puppet-2.6.8 spec/integration/node/facts_spec.rb
puppet-2.6.7 spec/integration/node/facts_spec.rb
puppet-2.6.6 spec/integration/node/facts_spec.rb
puppet-2.6.5 spec/integration/node/facts_spec.rb
puppet-2.6.4 spec/integration/node/facts_spec.rb
puppet-2.6.3 spec/integration/node/facts_spec.rb
puppet-2.6.2 spec/integration/node/facts_spec.rb
puppet-2.6.1 spec/integration/node/facts_spec.rb
puppet-2.6.0 spec/integration/node/facts_spec.rb