~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to spec/unit/indirector/catalog/compiler_spec.rb

  • Committer: Benjamin Kerensa
  • Date: 2012-11-21 23:50:52 UTC
  • mfrom: (1.1.30)
  • Revision ID: bkerensa@ubuntu.com-20121121235052-ah7nzabp77sh69gb
New Upstream Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env rspec
 
1
#! /usr/bin/env ruby
2
2
require 'spec_helper'
3
3
 
4
4
require 'puppet/indirector/catalog/compiler'
28
28
      node1 = stub 'node1', :merge => nil
29
29
      node2 = stub 'node2', :merge => nil
30
30
      compiler.stubs(:compile)
31
 
      Puppet::Node.indirection.stubs(:find).with('node1').returns(node1)
32
 
      Puppet::Node.indirection.stubs(:find).with('node2').returns(node2)
 
31
      Puppet::Node.indirection.stubs(:find).with('node1', anything).returns(node1)
 
32
      Puppet::Node.indirection.stubs(:find).with('node2', anything).returns(node2)
33
33
 
34
 
      compiler.find(stub('request', :key => 'node1', :node => 'node1', :options => {}))
35
 
      compiler.find(stub('node2request', :key => 'node2', :node => 'node2', :options => {}))
 
34
      compiler.find(Puppet::Indirector::Request.new(:catalog, :find, 'node1', nil, :node => 'node1'))
 
35
      compiler.find(Puppet::Indirector::Request.new(:catalog, :find, 'node2', nil, :node => 'node2'))
36
36
    end
37
37
 
38
38
    it "should provide a method for determining if the catalog is networked" do
50
50
      @node = Puppet::Node.new @name
51
51
      @node.stubs(:merge)
52
52
      Puppet::Node.indirection.stubs(:find).returns @node
53
 
      @request = stub 'request', :key => @name, :node => @name, :options => {}
 
53
      @request = Puppet::Indirector::Request.new(:catalog, :find, @name, nil, :node => @name)
54
54
    end
55
55
 
56
56
    it "should directly use provided nodes" do
62
62
 
63
63
    it "should use the authenticated node name if no request key is provided" do
64
64
      @request.stubs(:key).returns(nil)
65
 
      Puppet::Node.indirection.expects(:find).with(@name).returns(@node)
 
65
      Puppet::Node.indirection.expects(:find).with(@name, anything).returns(@node)
66
66
      @compiler.expects(:compile).with(@node)
67
67
      @compiler.find(@request)
68
68
    end
70
70
    it "should use the provided node name by default" do
71
71
      @request.expects(:key).returns "my_node"
72
72
 
73
 
      Puppet::Node.indirection.expects(:find).with("my_node").returns @node
 
73
      Puppet::Node.indirection.expects(:find).with("my_node", anything).returns @node
74
74
      @compiler.expects(:compile).with(@node)
75
75
      @compiler.find(@request)
76
76
    end
77
77
 
78
78
    it "should fail if no node is passed and none can be found" do
79
 
      Puppet::Node.indirection.stubs(:find).with(@name).returns(nil)
 
79
      Puppet::Node.indirection.stubs(:find).with(@name, anything).returns(nil)
80
80
      proc { @compiler.find(@request) }.should raise_error(ArgumentError)
81
81
    end
82
82
 
83
83
    it "should fail intelligently when searching for a node raises an exception" do
84
 
      Puppet::Node.indirection.stubs(:find).with(@name).raises "eh"
 
84
      Puppet::Node.indirection.stubs(:find).with(@name, anything).raises "eh"
85
85
      proc { @compiler.find(@request) }.should raise_error(Puppet::Error)
86
86
    end
87
87
 
88
88
    it "should pass the found node to the compiler for compiling" do
89
 
      Puppet::Node.indirection.expects(:find).with(@name).returns(@node)
 
89
      Puppet::Node.indirection.expects(:find).with(@name, anything).returns(@node)
90
90
      config = mock 'config'
91
91
      Puppet::Parser::Compiler.expects(:compile).with(@node)
92
92
      @compiler.find(@request)
93
93
    end
94
94
 
95
95
    it "should extract and save any facts from the request" do
96
 
      Puppet::Node.indirection.expects(:find).with(@name).returns @node
 
96
      Puppet::Node.indirection.expects(:find).with(@name, anything).returns @node
97
97
      @compiler.expects(:extract_facts_from_request).with(@request)
98
98
      Puppet::Parser::Compiler.stubs(:compile)
99
99
      @compiler.find(@request)
184
184
      @compiler = Puppet::Resource::Catalog::Compiler.new
185
185
      @name = "me"
186
186
      @node = mock 'node'
187
 
      @request = stub 'request', :key => @name, :options => {}
 
187
      @request = Puppet::Indirector::Request.new(:catalog, :find, @name, nil)
188
188
      @compiler.stubs(:compile)
189
189
    end
190
190
 
191
191
    it "should look node information up via the Node class with the provided key" do
192
192
      @node.stubs :merge
193
 
      Puppet::Node.indirection.expects(:find).with(@name).returns(@node)
 
193
      Puppet::Node.indirection.expects(:find).with(@name, anything).returns(@node)
194
194
      @compiler.find(@request)
195
195
    end
196
196
  end
203
203
      @compiler = Puppet::Resource::Catalog::Compiler.new
204
204
      @name = "me"
205
205
      @node = mock 'node'
206
 
      @request = stub 'request', :key => @name, :options => {}
 
206
      @request = Puppet::Indirector::Request.new(:catalog, :find, @name, nil)
207
207
      @compiler.stubs(:compile)
208
 
      Puppet::Node.indirection.stubs(:find).with(@name).returns(@node)
 
208
      Puppet::Node.indirection.stubs(:find).with(@name, anything).returns(@node)
209
209
    end
210
210
 
211
211
    it "should add the server's Puppet version to the node's parameters as 'serverversion'" do