~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to spec/integration/resource/catalog.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
#
 
3
#  Created by Luke Kanies on 2007-4-8.
 
4
#  Copyright (c) 2008. All rights reserved.
 
5
 
 
6
require File.dirname(__FILE__) + '/../../spec_helper'
 
7
 
 
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)
 
13
        end
 
14
    end
 
15
 
 
16
    describe "when using the indirector" do
 
17
        after { Puppet::Util::Cacher.expire }
 
18
        before do
 
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")
 
22
        end
 
23
 
 
24
 
 
25
        it "should be able to delegate to the :yaml terminus" do
 
26
            Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :yaml
 
27
 
 
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"
 
31
 
 
32
            FileTest.expects(:exist?).with("/my/yaml/file").returns false
 
33
            Puppet::Resource::Catalog.find("me").should be_nil
 
34
        end
 
35
 
 
36
        it "should be able to delegate to the :compiler terminus" do
 
37
            Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :compiler
 
38
 
 
39
            # Load now, before we stub the exists? method.
 
40
            compiler = Puppet::Resource::Catalog.indirection.terminus(:compiler)
 
41
 
 
42
            node = mock 'node'
 
43
            node.stub_everything
 
44
 
 
45
            Puppet::Node.expects(:find).returns(node)
 
46
            compiler.expects(:compile).with(node).returns nil
 
47
 
 
48
            Puppet::Resource::Catalog.find("me").should be_nil
 
49
        end
 
50
 
 
51
        it "should pass provided node information directly to the terminus" do
 
52
            terminus = mock 'terminus'
 
53
 
 
54
            Puppet::Resource::Catalog.indirection.stubs(:terminus).returns terminus
 
55
 
 
56
            node = mock 'node'
 
57
            terminus.expects(:find).with { |request| request.options[:use_node] == node }
 
58
            Puppet::Resource::Catalog.find("me", :use_node => node)
 
59
        end
 
60
    end
 
61
end