Sha256: 73387f4b804b96a50e97e1f10539aa7574fc3bc755b70a8d5db0d23806168b7e

Contents?: true

Size: 1.52 KB

Versions: 278

Compression:

Stored size: 1.52 KB

Contents

#! /usr/bin/env ruby
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
      Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml

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

      Puppet::Node.indirection.expects(:expire).with("me", optionally(instance_of(Hash)))

      facts = Puppet::Node::Facts.new("me")
      Puppet::Node::Facts.indirection.save(facts)
    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"
      Puppet::FileSystem.expects(:exist?).with("/my/yaml/file").returns false

      expect(Puppet::Node::Facts.indirection.find("me")).to 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

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

Version data entries

278 entries across 278 versions & 1 rubygems

Version Path
puppet-6.4.0 spec/integration/node/facts_spec.rb
puppet-6.4.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-6.4.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-6.4.0-universal-darwin spec/integration/node/facts_spec.rb
puppet-6.0.7 spec/integration/node/facts_spec.rb
puppet-6.0.7-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-6.0.7-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-6.0.7-universal-darwin spec/integration/node/facts_spec.rb
puppet-5.5.12 spec/integration/node/facts_spec.rb
puppet-5.5.12-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-5.5.12-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-5.5.12-universal-darwin spec/integration/node/facts_spec.rb
puppet-6.3.0 spec/integration/node/facts_spec.rb
puppet-6.3.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-6.3.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-6.3.0-universal-darwin spec/integration/node/facts_spec.rb
puppet-6.2.0 spec/integration/node/facts_spec.rb
puppet-6.2.0-x86-mingw32 spec/integration/node/facts_spec.rb
puppet-6.2.0-x64-mingw32 spec/integration/node/facts_spec.rb
puppet-6.2.0-universal-darwin spec/integration/node/facts_spec.rb