summaryrefslogtreecommitdiffstats
path: root/spec/unit/indirector
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-08-15 10:36:03 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-08-15 10:36:03 -0700
commite7d5c7c1cd4109d7bb061a503f5da8777a1be66d (patch)
tree6aace815f8c3fe30d4ad7eefbda8af141b78482f /spec/unit/indirector
parenta71573cb32f01e5bf5f1a5030c6a291ce5b63370 (diff)
parentfa1ec4dd93f015c2943271c9ae107991c6d3c90e (diff)
downloadpuppet-e7d5c7c1cd4109d7bb061a503f5da8777a1be66d.tar.gz
puppet-e7d5c7c1cd4109d7bb061a503f5da8777a1be66d.tar.xz
puppet-e7d5c7c1cd4109d7bb061a503f5da8777a1be66d.zip
Merge branch '2.7.x'
* 2.7.x: (25 commits) (#4411) Explain that runinterval = 0 does not mean "never run" Maint: Fix missing option text in puppet agent and arrange options alphabetically (#8302) Improve documentation of exec providers (#7853) Clarify and complete docs for the tagmail report processor Maint: Mention that audit metaparameter will accept "all" Maint: Adjust wording for file type's content parameter Maint: Fix poor documentation for versioncmp function. maint: Fix case sensitive require maint: Add inspect app options to help maint: Fix inspect help Increment lib/puppet.rb VERSION string Updated CHANGELOG for 2.7.3rc1 (#4762) Ensure that clients on the moon can successfully connect. Add document outlining preferred contribution methods Add document outlining preferred contribution methods Add document outlining preferred contribution methods Revert "Merge branch 'vcsrepo'" Revert "Merge branch 'vcsrepo'" Updating CHANGELOG for 2.7.2rc3 (#8704) Give better errors for invalid fileserver.conf ... Manually Resolved Conflicts: lib/puppet/parser/functions/versioncmp.rb spec/integration/node/facts_spec.rb
Diffstat (limited to 'spec/unit/indirector')
-rwxr-xr-xspec/unit/indirector/report/processor_spec.rb27
-rwxr-xr-xspec/unit/indirector/yaml_spec.rb18
2 files changed, 42 insertions, 3 deletions
diff --git a/spec/unit/indirector/report/processor_spec.rb b/spec/unit/indirector/report/processor_spec.rb
index fbc70a104..c64cc7eff 100755
--- a/spec/unit/indirector/report/processor_spec.rb
+++ b/spec/unit/indirector/report/processor_spec.rb
@@ -15,15 +15,21 @@ describe Puppet::Transaction::Report::Processor do
it "should provide a method for saving reports" do
Puppet::Transaction::Report::Processor.new.should respond_to(:save)
end
+
+ it "should provide a method for cleaning reports" do
+ Puppet::Transaction::Report::Processor.new.should respond_to(:destroy)
+ end
+
end
-describe Puppet::Transaction::Report::Processor, " when saving a report" do
+describe Puppet::Transaction::Report::Processor, " when processing a report" do
before do
Puppet.settings.stubs(:use)
@reporter = Puppet::Transaction::Report::Processor.new
+ @request = stub 'request', :instance => stub("report", :host => 'hostname'), :key => 'node'
end
- it "should not process the report if reports are set to 'none'" do
+ it "should not save the report if reports are set to 'none'" do
Puppet::Reports.expects(:report).never
Puppet[:reports] = 'none'
@@ -34,9 +40,24 @@ describe Puppet::Transaction::Report::Processor, " when saving a report" do
@reporter.save(request)
end
- it "should process the report with each configured report type" do
+ it "should save the report with each configured report type" do
Puppet.settings.stubs(:value).with(:reports).returns("one,two")
@reporter.send(:reports).should == %w{one two}
+
+ Puppet::Reports.expects(:report).with('one')
+ Puppet::Reports.expects(:report).with('two')
+
+ @reporter.save(@request)
+ end
+
+ it "should destroy reports for each processor that responds to destroy" do
+ Puppet.settings.stubs(:value).with(:reports).returns("http,store")
+ http_report = mock()
+ store_report = mock()
+ store_report.expects(:destroy).with(@request.key)
+ Puppet::Reports.expects(:report).with('http').returns(http_report)
+ Puppet::Reports.expects(:report).with('store').returns(store_report)
+ @reporter.destroy(@request)
end
end
diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb
index c43dbcaf6..29f6d466f 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -154,5 +154,23 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
Dir.expects(:glob).with(:glob).returns []
@store.search(@request).should == []
end
+
+ describe Puppet::Indirector::Yaml, " when destroying" do
+ it "should unlink the right yaml file if it exists" do
+ path = File.join("/what/ever", @store.class.indirection_name.to_s, @request.key.to_s + ".yaml")
+ File.expects(:exists?).with(path).returns true
+ File.expects(:unlink).with(path)
+
+ @store.destroy(@request)
+ end
+
+ it "should not unlink the yaml file if it does not exists" do
+ path = File.join("/what/ever", @store.class.indirection_name.to_s, @request.key.to_s + ".yaml")
+ File.expects(:exists?).with(path).returns false
+ File.expects(:unlink).with(path).never
+
+ @store.destroy(@request)
+ end
+ end
end
end