summaryrefslogtreecommitdiffstats
path: root/spec/unit/reports
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-01-06 17:39:03 -0800
committerNick Lewis <nick@puppetlabs.com>2011-01-06 17:39:03 -0800
commit8aa8b9dbc2437cea8109e4d272018437afe13794 (patch)
treeed5b8530e366b692a63ec9754a3204c0e48a3167 /spec/unit/reports
parent83ac3e789ddc8dbf40c93460032474870fb16c54 (diff)
downloadpuppet-8aa8b9dbc2437cea8109e4d272018437afe13794.tar.gz
puppet-8aa8b9dbc2437cea8109e4d272018437afe13794.tar.xz
puppet-8aa8b9dbc2437cea8109e4d272018437afe13794.zip
(#5799) Simplify report dir creation
This report processor was unnecessarily using Puppet to create a single directory. This was causing complex failures in any spec dealing with reports. Paired-With: Paul Berry
Diffstat (limited to 'spec/unit/reports')
-rw-r--r--spec/unit/reports/store_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/unit/reports/store_spec.rb b/spec/unit/reports/store_spec.rb
new file mode 100644
index 000000000..1acb5badd
--- /dev/null
+++ b/spec/unit/reports/store_spec.rb
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+require 'puppet/reports'
+require 'time'
+
+processor = Puppet::Reports.report(:store)
+
+describe processor do
+ describe "#process" do
+ include PuppetSpec::Files
+ before :each do
+ Puppet[:reportdir] = tmpdir('reports')
+ @report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml')).extend processor
+ end
+
+ it "should create a report directory for the client if one doesn't exist" do
+ @report.process
+
+ File.should be_directory(File.join(Puppet[:reportdir], @report.host))
+ end
+
+ it "should write the report to the file in YAML" do
+ Time.stubs(:now).returns(Time.parse("2011-01-06 12:00:00 UTC"))
+ @report.process
+
+ File.read(File.join(Puppet[:reportdir], @report.host, "201101061200.yaml")).should == @report.to_yaml
+ end
+ end
+end