~ubuntu-branches/ubuntu/trusty/puppet/trusty

« back to all changes in this revision

Viewing changes to spec/unit/indirector/report/processor_spec.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-10-22 14:08:22 UTC
  • mfrom: (1.1.25) (3.1.32 sid)
  • Revision ID: package-import@ubuntu.com-20111022140822-odxde5lohc45yhuz
Tags: 2.7.6-1
* New upstream release (CVE-2011-3872)
* Remove cherry-picked "groupadd_aix_warning" patch
* Install all new manpages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env rspec
2
 
#
3
 
#  Created by Luke Kanies on 2007-9-23.
4
 
#  Copyright (c) 2007. All rights reserved.
5
 
 
6
2
require 'spec_helper'
7
3
 
8
4
require 'puppet/indirector/report/processor'
15
11
  it "should provide a method for saving reports" do
16
12
    Puppet::Transaction::Report::Processor.new.should respond_to(:save)
17
13
  end
 
14
 
 
15
  it "should provide a method for cleaning reports" do
 
16
    Puppet::Transaction::Report::Processor.new.should respond_to(:destroy)
 
17
  end
 
18
 
18
19
end
19
20
 
20
 
describe Puppet::Transaction::Report::Processor, " when saving a report" do
 
21
describe Puppet::Transaction::Report::Processor, " when processing a report" do
21
22
  before do
22
23
    Puppet.settings.stubs(:use)
23
24
    @reporter = Puppet::Transaction::Report::Processor.new
 
25
    @request = stub 'request', :instance => stub("report", :host => 'hostname'), :key => 'node'
24
26
  end
25
27
 
26
 
  it "should not process the report if reports are set to 'none'" do
 
28
  it "should not save the report if reports are set to 'none'" do
27
29
    Puppet::Reports.expects(:report).never
28
 
    Puppet.settings.expects(:value).with(:reports).returns("none")
 
30
    Puppet[:reports] = 'none'
29
31
 
30
 
    request = stub 'request', :instance => mock("report")
 
32
    request = Puppet::Indirector::Request.new(:indirection_name, :head, "key")
 
33
    report = Puppet::Transaction::Report.new('apply')
 
34
    request.instance = report
31
35
 
32
36
    @reporter.save(request)
33
37
  end
34
38
 
35
 
  it "should process the report with each configured report type" do
 
39
  it "should save the report with each configured report type" do
36
40
    Puppet.settings.stubs(:value).with(:reports).returns("one,two")
37
41
    @reporter.send(:reports).should == %w{one two}
 
42
 
 
43
    Puppet::Reports.expects(:report).with('one')
 
44
    Puppet::Reports.expects(:report).with('two')
 
45
 
 
46
    @reporter.save(@request)
 
47
  end
 
48
 
 
49
  it "should destroy reports for each processor that responds to destroy" do
 
50
    Puppet.settings.stubs(:value).with(:reports).returns("http,store")
 
51
    http_report = mock()
 
52
    store_report = mock()
 
53
    store_report.expects(:destroy).with(@request.key)
 
54
    Puppet::Reports.expects(:report).with('http').returns(http_report)
 
55
    Puppet::Reports.expects(:report).with('store').returns(store_report)
 
56
    @reporter.destroy(@request)
38
57
  end
39
58
end
40
59
 
41
60
describe Puppet::Transaction::Report::Processor, " when processing a report" do
42
61
  before do
43
 
    Puppet.settings.stubs(:value).with(:reports).returns("one")
 
62
    Puppet[:reports] = "one"
44
63
    Puppet.settings.stubs(:use)
45
64
    @reporter = Puppet::Transaction::Report::Processor.new
46
65
 
47
66
    @report_type = mock 'one'
48
67
    @dup_report = mock 'dupe report'
49
68
    @dup_report.stubs(:process)
50
 
    @report = mock 'report'
 
69
    @report = Puppet::Transaction::Report.new('apply')
51
70
    @report.expects(:dup).returns(@dup_report)
52
71
 
53
72
    @request = stub 'request', :instance => @report
74
93
  end
75
94
 
76
95
  it "should not raise exceptions" do
77
 
    Puppet.settings.stubs(:value).with(:trace).returns(false)
 
96
    Puppet[:trace] = false
78
97
    @dup_report.expects(:process).raises(ArgumentError)
79
98
    proc { @reporter.save(@request) }.should_not raise_error
80
99
  end