3
# Created by Luke Kanies on 2007-4-8.
4
# Copyright (c) 2008. All rights reserved.
6
require File.dirname(__FILE__) + '/../../spec_helper'
8
describe Puppet::Resource::Catalog do
9
describe "when pson is available" do
10
confine "PSON library is missing" => Puppet.features.pson?
11
it "should support pson" do
12
Puppet::Resource::Catalog.supported_formats.should be_include(:pson)
16
describe "when using the indirector" do
17
after { Puppet::Util::Cacher.expire }
19
# This is so the tests work w/out networking.
20
Facter.stubs(:to_hash).returns({"hostname" => "foo.domain.com"})
21
Facter.stubs(:value).returns("eh")
25
it "should be able to delegate to the :yaml terminus" do
26
Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :yaml
28
# Load now, before we stub the exists? method.
29
terminus = Puppet::Resource::Catalog.indirection.terminus(:yaml)
30
terminus.expects(:path).with("me").returns "/my/yaml/file"
32
FileTest.expects(:exist?).with("/my/yaml/file").returns false
33
Puppet::Resource::Catalog.find("me").should be_nil
36
it "should be able to delegate to the :compiler terminus" do
37
Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :compiler
39
# Load now, before we stub the exists? method.
40
compiler = Puppet::Resource::Catalog.indirection.terminus(:compiler)
45
Puppet::Node.expects(:find).returns(node)
46
compiler.expects(:compile).with(node).returns nil
48
Puppet::Resource::Catalog.find("me").should be_nil
51
it "should pass provided node information directly to the terminus" do
52
terminus = mock 'terminus'
54
Puppet::Resource::Catalog.indirection.stubs(:terminus).returns terminus
57
terminus.expects(:find).with { |request| request.options[:use_node] == node }
58
Puppet::Resource::Catalog.find("me", :use_node => node)