diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-01-05 15:54:00 -0800 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-01-05 15:54:00 -0800 |
| commit | 19eb1e78e115d10bfb822e510213e4fab9cd2599 (patch) | |
| tree | d5068dfd7a3890c7b5961779c87681b930cf3144 /spec/unit/application | |
| parent | cc1f2b39a65e8b74c8e59a2bf7d8f47a35985ee4 (diff) | |
| parent | 83ac3e789ddc8dbf40c93460032474870fb16c54 (diff) | |
| download | puppet-19eb1e78e115d10bfb822e510213e4fab9cd2599.tar.gz puppet-19eb1e78e115d10bfb822e510213e4fab9cd2599.tar.xz puppet-19eb1e78e115d10bfb822e510213e4fab9cd2599.zip | |
Merge branch '2.6.next' into 2.6.x
Diffstat (limited to 'spec/unit/application')
| -rwxr-xr-x | spec/unit/application/apply_spec.rb | 14 | ||||
| -rw-r--r-- | spec/unit/application/inspect_spec.rb | 25 | ||||
| -rwxr-xr-x | spec/unit/application/kick_spec.rb | 4 | ||||
| -rw-r--r-- | spec/unit/application/master_spec.rb | 4 |
4 files changed, 33 insertions, 14 deletions
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index 877c47bcc..4e1744206 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -4,6 +4,7 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/application/apply' require 'puppet/file_bucket/dipper' +require 'puppet/configurer' describe Puppet::Application::Apply do before :each do @@ -194,6 +195,9 @@ describe Puppet::Application::Apply do @catalog.stubs(:apply).returns(@transaction) @apply.stubs(:exit) + + Puppet::Util::Storage.stubs(:load) + Puppet::Configurer.any_instance.stubs(:save_last_run_summary) # to prevent it from trying to write files end it "should set the code to run from --code" do @@ -302,11 +306,8 @@ describe Puppet::Application::Apply do end it "should call the prerun and postrun commands on a Configurer instance" do - configurer = stub 'configurer' - - Puppet::Configurer.expects(:new).returns configurer - configurer.expects(:execute_prerun_command) - configurer.expects(:execute_postrun_command) + Puppet::Configurer.any_instance.expects(:execute_prerun_command) + Puppet::Configurer.any_instance.expects(:execute_postrun_command) @apply.main end @@ -321,8 +322,7 @@ describe Puppet::Application::Apply do it "should exit with report's computed exit status" do Puppet.stubs(:[]).with(:noop).returns(false) @apply.options.stubs(:[]).with(:detailed_exitcodes).returns(true) - report = stub 'report', :exit_status => 666 - @transaction.stubs(:report).returns(report) + Puppet::Transaction::Report.any_instance.stubs(:exit_status).returns(666) @apply.expects(:exit).with(666) @apply.main diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb index a3cc74d86..b931708c3 100644 --- a/spec/unit/application/inspect_spec.rb +++ b/spec/unit/application/inspect_spec.rb @@ -51,7 +51,7 @@ describe Puppet::Application::Inspect do catalog = Puppet::Resource::Catalog.new file = Tempfile.new("foo") file.puts("file contents") - file.flush + file.close resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"}) catalog.add_resource(resource) Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog) @@ -69,6 +69,29 @@ describe Puppet::Application::Inspect do end properties["ensure"].should == :file properties["content"].should == "{md5}#{Digest::MD5.hexdigest("file contents\n")}" + properties.has_key?("target").should == false + end + + it "should not report irrelevent attributes if the resource is absent" do + catalog = Puppet::Resource::Catalog.new + file = Tempfile.new("foo") + resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"}) + file.delete + catalog.add_resource(resource) + Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog) + + events = nil + + Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| + events = request.instance.resource_statuses.values.first.events + end + + @inspect.run_command + + properties = events.inject({}) do |property_values, event| + property_values.merge(event.property => event.previous_value) + end + properties.should == {"ensure" => :absent} end end diff --git a/spec/unit/application/kick_spec.rb b/spec/unit/application/kick_spec.rb index dea7ec147..c18a84de3 100755 --- a/spec/unit/application/kick_spec.rb +++ b/spec/unit/application/kick_spec.rb @@ -4,9 +4,7 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/application/kick' -describe Puppet::Application::Kick do - - confine "Kick's eventloops can only start on POSIX" => Puppet.features.posix? +describe Puppet::Application::Kick, :if => Puppet.features.posix? do before :each do require 'puppet/util/ldap/connection' diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb index 216c7dc90..074249a4d 100644 --- a/spec/unit/application/master_spec.rb +++ b/spec/unit/application/master_spec.rb @@ -412,9 +412,7 @@ describe Puppet::Application::Master do @master.main end - describe "with --rack" do - confine "Rack is not available" => Puppet.features.rack? - + describe "with --rack", :if => Puppet.features.rack? do before do require 'puppet/network/http/rack' Puppet::Network::HTTP::Rack.stubs(:new).returns(@app) |
