~nvalcarcel/ubuntu/lucid/puppet/fix-546677

« back to all changes in this revision

Viewing changes to spec/integration/indirector/catalog/queue.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
Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
 
4
 
 
5
require 'puppet/resource/catalog'
 
6
 
 
7
 
 
8
describe "Puppet::Resource::Catalog::Queue" do
 
9
    confine "Missing pson support; cannot test queue" => Puppet.features.pson?
 
10
 
 
11
    before do
 
12
        Puppet::Resource::Catalog.indirection.terminus(:queue)
 
13
        @catalog = Puppet::Resource::Catalog.new
 
14
 
 
15
        @one = Puppet::Resource.new(:file, "/one")
 
16
        @two = Puppet::Resource.new(:file, "/two")
 
17
        @catalog.add_resource(@one, @two)
 
18
 
 
19
        @catalog.add_edge(@one, @two)
 
20
 
 
21
        Puppet[:trace] = true
 
22
    end
 
23
 
 
24
    after { Puppet.settings.clear }
 
25
 
 
26
    it "should render catalogs to pson and send them via the queue client when catalogs are saved" do
 
27
        terminus = Puppet::Resource::Catalog.indirection.terminus(:queue)
 
28
 
 
29
        client = mock 'client'
 
30
        terminus.stubs(:client).returns client
 
31
 
 
32
        client.expects(:send_message).with(:catalog, @catalog.to_pson)
 
33
 
 
34
        request = Puppet::Indirector::Request.new(:catalog, :save, "foo", :instance => @catalog)
 
35
 
 
36
        terminus.save(request)
 
37
    end
 
38
 
 
39
    it "should intern catalog messages when they are passed via a subscription" do
 
40
        client = mock 'client'
 
41
        Puppet::Resource::Catalog::Queue.stubs(:client).returns client
 
42
 
 
43
        pson = @catalog.to_pson
 
44
 
 
45
        client.expects(:subscribe).with(:catalog).yields(pson)
 
46
 
 
47
        Puppet.expects(:err).never
 
48
 
 
49
        result = []
 
50
        Puppet::Resource::Catalog::Queue.subscribe do |catalog|
 
51
            result << catalog
 
52
        end
 
53
 
 
54
        catalog = result.shift
 
55
        catalog.should be_instance_of(Puppet::Resource::Catalog)
 
56
 
 
57
        catalog.resource(:file, "/one").should be_instance_of(Puppet::Resource)
 
58
        catalog.resource(:file, "/two").should be_instance_of(Puppet::Resource)
 
59
        catalog.should be_edge(catalog.resource(:file, "/one"), catalog.resource(:file, "/two"))
 
60
    end
 
61
end