summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-01-07 13:58:44 -0800
committerNick Lewis <nick@puppetlabs.com>2011-01-07 13:58:44 -0800
commit78e838ad3cc08d8e155d895a478ee73f616440d7 (patch)
tree91d482964b4e470e9e180811387564118bba07fd /spec/unit
parent824907ce0abed0e8c332b873b88705fbccf0d24e (diff)
parent27abd84611564ac573c5fde8abb6b98e6bd3d9b7 (diff)
Merge branch 'next'
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/application/agent_spec.rb8
-rwxr-xr-xspec/unit/application/apply_spec.rb2
-rw-r--r--spec/unit/application/master_spec.rb19
-rwxr-xr-xspec/unit/configurer_spec.rb15
-rw-r--r--spec/unit/reports/store_spec.rb31
5 files changed, 41 insertions, 34 deletions
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index be397073c..cee6a0d1a 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -293,14 +293,6 @@ describe Puppet::Application::Agent do
@puppetd.setup
end
- it "mocha work-around" do
- # Mocha 0.9.10 and earlier leaves behind a bogus "use" method
- # See https://github.com/floehopper/mocha/issues#issue/20
- class << Puppet.settings
- remove_method :use rescue nil
- end
- end
-
it "should install a remote ca location" do
Puppet::SSL::Host.expects(:ca_location=).with(:remote)
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index 9485ed221..8aaa5d8f9 100755
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -177,7 +177,7 @@ describe Puppet::Application::Apply do
describe "the main command" do
before :each do
Puppet.stubs(:[])
- Puppet::Util::Settings.any_instance.stubs(:use)
+ Puppet.settings.stubs(:use)
Puppet.stubs(:[]).with(:prerun_command).returns ""
Puppet.stubs(:[]).with(:postrun_command).returns ""
Puppet.stubs(:[]).with(:trace).returns(true)
diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb
index 1cf06ffa6..1173752d9 100644
--- a/spec/unit/application/master_spec.rb
+++ b/spec/unit/application/master_spec.rb
@@ -119,7 +119,7 @@ describe Puppet::Application::Master do
Puppet::Log.stubs(:level=)
Puppet::SSL::CertificateAuthority.stubs(:instance)
Puppet::SSL::CertificateAuthority.stubs(:ca?)
- Puppet::Util::Settings.any_instance.stubs(:use)
+ Puppet.settings.stubs(:use)
@master.options.stubs(:[]).with(any_parameters)
end
@@ -183,14 +183,6 @@ describe Puppet::Application::Master do
@master.setup
end
- it "mocha work-around" do
- # Mocha 0.9.10 and earlier leaves behind a bogus "use" method
- # See https://github.com/floehopper/mocha/issues#issue/20
- class << Puppet.settings
- remove_method :use rescue nil
- end
- end
-
it "should cache class in yaml" do
Puppet::Node.indirection.expects(:cache_class=).with(:yaml)
@@ -220,20 +212,11 @@ describe Puppet::Application::Master do
end
it "should tell Puppet.settings to use :ca category" do
- Puppet.settings.stubs(:use)
Puppet.settings.expects(:use).with(:ca)
@master.setup
end
- it "mocha work-around" do
- # Mocha 0.9.10 and earlier leaves behind a bogus "use" method
- # See https://github.com/floehopper/mocha/issues#issue/20
- class << Puppet.settings
- remove_method :use rescue nil
- end
- end
-
it "should instantiate the CertificateAuthority singleton" do
Puppet::SSL::CertificateAuthority.expects(:instance)
diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb
index 6b4998c65..f8acdd002 100755
--- a/spec/unit/configurer_spec.rb
+++ b/spec/unit/configurer_spec.rb
@@ -8,7 +8,7 @@ require 'puppet/configurer'
describe Puppet::Configurer do
before do
- Puppet::Util::Settings.any_instance.stubs(:use).returns(true)
+ Puppet.settings.stubs(:use).returns(true)
@agent = Puppet::Configurer.new
end
@@ -74,7 +74,7 @@ end
describe Puppet::Configurer, "when executing a catalog run" do
before do
- Puppet::Util::Settings.any_instance.stubs(:use).returns(true)
+ Puppet.settings.stubs(:use).returns(true)
@agent = Puppet::Configurer.new
@agent.stubs(:prepare)
@agent.stubs(:facts_for_uploading).returns({})
@@ -82,6 +82,7 @@ describe Puppet::Configurer, "when executing a catalog run" do
@catalog.stubs(:apply)
@agent.stubs(:retrieve_catalog).returns @catalog
@agent.stubs(:save_last_run_summary)
+ Puppet::Transaction::Report.indirection.stubs(:save)
end
it "should prepare for the run" do
@@ -226,7 +227,7 @@ end
describe Puppet::Configurer, "when sending a report" do
before do
- Puppet::Util::Settings.any_instance.stubs(:use).returns(true)
+ Puppet.settings.stubs(:use).returns(true)
@configurer = Puppet::Configurer.new
@configurer.stubs(:save_last_run_summary)
@@ -295,7 +296,7 @@ end
describe Puppet::Configurer, "when saving the summary report file" do
before do
- Puppet::Util::Settings.any_instance.stubs(:use).returns(true)
+ Puppet.settings.stubs(:use).returns(true)
@configurer = Puppet::Configurer.new
@report = stub 'report'
@@ -325,7 +326,7 @@ end
describe Puppet::Configurer, "when retrieving a catalog" do
before do
- Puppet::Util::Settings.any_instance.stubs(:use).returns(true)
+ Puppet.settings.stubs(:use).returns(true)
@agent = Puppet::Configurer.new
@agent.stubs(:facts_for_uploading).returns({})
@@ -455,7 +456,7 @@ end
describe Puppet::Configurer, "when converting the catalog" do
before do
- Puppet::Util::Settings.any_instance.stubs(:use).returns(true)
+ Puppet.settings.stubs(:use).returns(true)
@agent = Puppet::Configurer.new
@catalog = Puppet::Resource::Catalog.new
@@ -489,7 +490,7 @@ end
describe Puppet::Configurer, "when preparing for a run" do
before do
- Puppet::Util::Settings.any_instance.stubs(:use).returns(true)
+ Puppet.settings.stubs(:use).returns(true)
@agent = Puppet::Configurer.new
@agent.stubs(:dostorage)
@agent.stubs(:download_fact_plugins)
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