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

« back to all changes in this revision

Viewing changes to test/network/handler/master.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env ruby
2
2
 
3
 
require File.dirname(__FILE__) + '/../../lib/puppettest'
 
3
require File.expand_path(File.dirname(__FILE__) + '/../../lib/puppettest')
4
4
 
5
5
require 'puppettest'
6
6
require 'puppet/network/handler/master'
13
13
    @master = Puppet::Network::Handler.master.new(:Manifest => tempfile)
14
14
 
15
15
    @catalog = stub 'catalog', :extract => ""
16
 
    Puppet::Resource::Catalog.stubs(:find).returns(@catalog)
 
16
    Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
17
17
  end
18
18
 
19
19
  def teardown
32
32
 
33
33
  def test_hostname_is_used_if_client_is_missing
34
34
    @master.expects(:decode_facts).returns("hostname" => "yay")
35
 
    Puppet::Node::Facts.expects(:new).with { |name, facts| name == "yay" }.returns(stub('facts', :save => nil))
 
35
    facts = Puppet::Node::Facts.new("the_facts")
 
36
    Puppet::Node::Facts.indirection.stubs(:save).with(facts)
 
37
    Puppet::Node::Facts.expects(:new).with { |name, facts| name == "yay" }.returns(facts)
36
38
 
37
39
    @master.getconfig("facts")
38
40
  end
39
41
 
40
42
  def test_facts_are_saved
41
 
    facts = mock('facts')
 
43
    facts = Puppet::Node::Facts.new("the_facts")
42
44
    Puppet::Node::Facts.expects(:new).returns(facts)
43
 
    facts.expects(:save)
 
45
    Puppet::Node::Facts.indirection.expects(:save).with(facts)
44
46
 
45
47
    @master.stubs(:decode_facts)
46
48
 
48
50
  end
49
51
 
50
52
  def test_catalog_is_used_for_compiling
51
 
    facts = stub('facts', :save => nil)
 
53
    facts = Puppet::Node::Facts.new("the_facts")
 
54
    Puppet::Node::Facts.indirection.stubs(:save).with(facts)
52
55
    Puppet::Node::Facts.stubs(:new).returns(facts)
53
56
 
54
57
    @master.stubs(:decode_facts)
55
58
 
56
 
    Puppet::Resource::Catalog.expects(:find).with("foo.com").returns(@catalog)
 
59
    Puppet::Resource::Catalog.indirection.expects(:find).with("foo.com").returns(@catalog)
57
60
 
58
61
    @master.getconfig("facts", "yaml", "foo.com")
59
62
  end
61
64
 
62
65
class TestMasterFormats < Test::Unit::TestCase
63
66
  def setup
64
 
    @facts = stub('facts', :save => nil)
 
67
    @facts = Puppet::Node::Facts.new("the_facts")
65
68
    Puppet::Node::Facts.stubs(:new).returns(@facts)
 
69
    Puppet::Node::Facts.indirection.stubs(:save)
66
70
 
67
71
    @master = Puppet::Network::Handler.master.new(:Code => "")
68
72
    @master.stubs(:decode_facts)
69
73
 
70
74
    @catalog = stub 'catalog', :extract => ""
71
 
    Puppet::Resource::Catalog.stubs(:find).returns(@catalog)
 
75
    Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog)
72
76
  end
73
77
 
74
78
  def test_marshal_can_be_used