Sha256: 76643331aeb9b3eba58af7fadbd81deace6fc8d6306adf0e168fd9389c64bbf9

Contents?: true

Size: 1.62 KB

Versions: 316

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe Puppet::Node::Facts do
  describe "when using the indirector" do
    it "should expire any cached node instances when it is saved" do
      allow(Puppet::Node::Facts.indirection).to receive(:terminus_class).and_return(:yaml)

      expect(Puppet::Node::Facts.indirection.terminus(:yaml)).to equal(Puppet::Node::Facts.indirection.terminus(:yaml))
      terminus = Puppet::Node::Facts.indirection.terminus(:yaml)
      allow(terminus).to receive(:save)

      expect(Puppet::Node.indirection).to receive(:expire).with("me", be_a(Hash).or(be_nil))

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

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

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

      expect(terminus).to receive(:path).with("me").and_return("/my/yaml/file")
      expect(Puppet::FileSystem).to receive(:exist?).with("/my/yaml/file").and_return(false)

      expect(Puppet::Node::Facts.indirection.find("me")).to be_nil
    end

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

      expect(Facter).to receive(:to_hash).and_return("facter_hash")
      facts = Puppet::Node::Facts.new("me")
      expect(Puppet::Node::Facts).to receive(:new).with("me", "facter_hash").and_return(facts)

      expect(Puppet::Node::Facts.indirection.find("me")).to equal(facts)
    end
  end
end

Version data entries

316 entries across 316 versions & 1 rubygems

Version Path
puppet-7.28.0 spec/integration/node/facts_spec.rb
puppet-7.28.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-7.28.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-7.28.0-universal-darwin spec/integration/node/facts_spec.rb
puppet-7.27.0 spec/integration/node/facts_spec.rb
puppet-7.27.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-7.27.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-7.27.0-universal-darwin spec/integration/node/facts_spec.rb
puppet-7.26.0 spec/integration/node/facts_spec.rb
puppet-7.26.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-7.26.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-7.26.0-universal-darwin spec/integration/node/facts_spec.rb
puppet-7.25.0 spec/integration/node/facts_spec.rb
puppet-7.25.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-7.25.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-7.25.0-universal-darwin spec/integration/node/facts_spec.rb
puppet-7.24.0 spec/integration/node/facts_spec.rb
puppet-7.24.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-7.24.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-7.24.0-universal-darwin spec/integration/node/facts_spec.rb