diff options
| author | Dominic Cleal <dcleal@redhat.com> | 2011-02-19 21:21:13 +0000 |
|---|---|---|
| committer | Dominic Cleal <dcleal@redhat.com> | 2011-02-19 21:21:13 +0000 |
| commit | c87ec2598700c4e5236452a016f0497ec848cb90 (patch) | |
| tree | 47a2435ef019bfcac2ec2aa388935173bc5c6b52 /spec/unit/application | |
| parent | 3eace859f20d9ac7366382826028af44c3ab62d6 (diff) | |
| parent | ea348761df0b5297dbac50c7f1c48d22746524fa (diff) | |
| download | puppet-c87ec2598700c4e5236452a016f0497ec848cb90.tar.gz puppet-c87ec2598700c4e5236452a016f0497ec848cb90.tar.xz puppet-c87ec2598700c4e5236452a016f0497ec848cb90.zip | |
Merge branch 'master' into tickets/master/4258-dev
Diffstat (limited to 'spec/unit/application')
| -rwxr-xr-x | spec/unit/application/agent_spec.rb | 24 | ||||
| -rwxr-xr-x | spec/unit/application/apply_spec.rb | 26 | ||||
| -rwxr-xr-x | spec/unit/application/cert_spec.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/application/describe_spec.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/application/doc_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/application/filebucket_spec.rb | 2 | ||||
| -rw-r--r-- | spec/unit/application/inspect_spec.rb | 278 | ||||
| -rwxr-xr-x | spec/unit/application/kick_spec.rb | 14 | ||||
| -rw-r--r-- | spec/unit/application/master_spec.rb | 29 | ||||
| -rwxr-xr-x | spec/unit/application/queue_spec.rb | 12 | ||||
| -rwxr-xr-x | spec/unit/application/resource_spec.rb | 26 |
11 files changed, 348 insertions, 73 deletions
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb index 50ef00c57..cee6a0d1a 100755 --- a/spec/unit/application/agent_spec.rb +++ b/spec/unit/application/agent_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/agent' require 'puppet/application/agent' @@ -21,9 +21,9 @@ describe Puppet::Application::Agent do Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) - Puppet::Node.stubs(:terminus_class=) - Puppet::Node.stubs(:cache_class=) - Puppet::Node::Facts.stubs(:terminus_class=) + Puppet::Node.indirection.stubs(:terminus_class=) + Puppet::Node.indirection.stubs(:cache_class=) + Puppet::Node::Facts.indirection.stubs(:terminus_class=) end it "should operate in agent run_mode" do @@ -179,11 +179,11 @@ describe Puppet::Application::Agent do FileTest.stubs(:exists?).returns(true) Puppet[:libdir] = "/dev/null/lib" Puppet::SSL::Host.stubs(:ca_location=) - Puppet::Transaction::Report.stubs(:terminus_class=) - Puppet::Transaction::Report.stubs(:cache_class=) - Puppet::Resource::Catalog.stubs(:terminus_class=) - Puppet::Resource::Catalog.stubs(:cache_class=) - Puppet::Node::Facts.stubs(:terminus_class=) + Puppet::Transaction::Report.indirection.stubs(:terminus_class=) + Puppet::Transaction::Report.indirection.stubs(:cache_class=) + Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) + Puppet::Resource::Catalog.indirection.stubs(:cache_class=) + Puppet::Node::Facts.indirection.stubs(:terminus_class=) @host = stub_everything 'host' Puppet::SSL::Host.stubs(:new).returns(@host) Puppet.stubs(:settraps) @@ -307,13 +307,13 @@ describe Puppet::Application::Agent do end it "should tell the report handler to use REST" do - Puppet::Transaction::Report.expects(:terminus_class=).with(:rest) + Puppet::Transaction::Report.indirection.expects(:terminus_class=).with(:rest) @puppetd.setup end it "should tell the report handler to cache locally as yaml" do - Puppet::Transaction::Report.expects(:cache_class=).with(:yaml) + Puppet::Transaction::Report.indirection.expects(:cache_class=).with(:yaml) @puppetd.setup end @@ -325,7 +325,7 @@ describe Puppet::Application::Agent do end it "should tell the catalog handler to use cache" do - Puppet::Resource::Catalog.expects(:cache_class=).with(:yaml) + Puppet::Resource::Catalog.indirection.expects(:cache_class=).with(:yaml) @puppetd.setup end diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index f07416378..8aaa5d8f9 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/apply' require 'puppet/file_bucket/dipper' @@ -57,7 +57,7 @@ describe Puppet::Application::Apply do Puppet.stubs(:parse_config) Puppet::FileBucket::Dipper.stubs(:new) STDIN.stubs(:read) - Puppet::Transaction::Report.stubs(:cache_class=) + Puppet::Transaction::Report.indirection.stubs(:cache_class=) @apply.options.stubs(:[]).with(any_parameters) end @@ -116,7 +116,7 @@ describe Puppet::Application::Apply do end it "should tell the report handler to cache locally as yaml" do - Puppet::Transaction::Report.expects(:cache_class=).with(:yaml) + Puppet::Transaction::Report.indirection.expects(:cache_class=).with(:yaml) @apply.setup end @@ -185,14 +185,14 @@ describe Puppet::Application::Apply do @apply.options.stubs(:[]) @facts = stub_everything 'facts' - Puppet::Node::Facts.stubs(:find).returns(@facts) + Puppet::Node::Facts.indirection.stubs(:find).returns(@facts) @node = stub_everything 'node' - Puppet::Node.stubs(:find).returns(@node) + Puppet::Node.indirection.stubs(:find).returns(@node) @catalog = stub_everything 'catalog' @catalog.stubs(:to_ral).returns(@catalog) - Puppet::Resource::Catalog.stubs(:find).returns(@catalog) + Puppet::Resource::Catalog.indirection.stubs(:find).returns(@catalog) STDIN.stubs(:read) @@ -248,25 +248,25 @@ describe Puppet::Application::Apply do end it "should collect the node facts" do - Puppet::Node::Facts.expects(:find).returns(@facts) + Puppet::Node::Facts.indirection.expects(:find).returns(@facts) @apply.main end it "should raise an error if we can't find the node" do - Puppet::Node::Facts.expects(:find).returns(nil) + Puppet::Node::Facts.indirection.expects(:find).returns(nil) lambda { @apply.main }.should raise_error end it "should look for the node" do - Puppet::Node.expects(:find).returns(@node) + Puppet::Node.indirection.expects(:find).returns(@node) @apply.main end it "should raise an error if we can't find the node" do - Puppet::Node.expects(:find).returns(nil) + Puppet::Node.indirection.expects(:find).returns(nil) lambda { @apply.main }.should raise_error end @@ -292,7 +292,7 @@ describe Puppet::Application::Apply do end it "should compile the catalog" do - Puppet::Resource::Catalog.expects(:find).returns(@catalog) + Puppet::Resource::Catalog.indirection.expects(:find).returns(@catalog) @apply.main end @@ -325,8 +325,8 @@ describe Puppet::Application::Apply do it "should save the last run summary" do Puppet.stubs(:[]).with(:noop).returns(false) - report = stub 'report' - Puppet::Configurer.any_instance.stubs(:initialize_report).returns(report) + report = Puppet::Transaction::Report.new("apply") + Puppet::Transaction::Report.stubs(:new).returns(report) Puppet::Configurer.any_instance.expects(:save_last_run_summary).with(report) @apply.main diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb index 4663fc938..c7f463ea2 100755 --- a/spec/unit/application/cert_spec.rb +++ b/spec/unit/application/cert_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/cert' diff --git a/spec/unit/application/describe_spec.rb b/spec/unit/application/describe_spec.rb index 7c64ff86d..47b98a17b 100755 --- a/spec/unit/application/describe_spec.rb +++ b/spec/unit/application/describe_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/describe' diff --git a/spec/unit/application/doc_spec.rb b/spec/unit/application/doc_spec.rb index 55da5e39a..f432184d3 100755 --- a/spec/unit/application/doc_spec.rb +++ b/spec/unit/application/doc_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/doc' require 'puppet/util/reference' @@ -48,10 +48,10 @@ describe Puppet::Application::Doc do @doc.options[:mode].should == :text end - it "should init format to to_rest" do + it "should init format to to_markdown" do @doc.preinit - @doc.options[:format].should == :to_rest + @doc.options[:format].should == :to_markdown end end diff --git a/spec/unit/application/filebucket_spec.rb b/spec/unit/application/filebucket_spec.rb index e6272f179..8b811d7c5 100644 --- a/spec/unit/application/filebucket_spec.rb +++ b/spec/unit/application/filebucket_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/filebucket' require 'puppet/file_bucket/dipper' diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb new file mode 100644 index 000000000..1d99c6ca9 --- /dev/null +++ b/spec/unit/application/inspect_spec.rb @@ -0,0 +1,278 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/application/inspect' +require 'puppet/resource/catalog' +require 'puppet/indirector/catalog/yaml' +require 'puppet/indirector/report/rest' +require 'puppet/indirector/file_bucket_file/rest' + +describe Puppet::Application::Inspect do + include PuppetSpec::Files + + before :each do + @inspect = Puppet::Application[:inspect] + end + + describe "during setup" do + it "should print its configuration if asked" do + Puppet[:configprint] = "all" + + Puppet.settings.expects(:print_configs).returns(true) + lambda { @inspect.setup }.should raise_error(SystemExit) + end + + it "should fail if reporting is turned off" do + Puppet[:report] = false + lambda { @inspect.setup }.should raise_error(/report=true/) + end + end + + describe "when executing" do + before :each do + Puppet[:report] = true + @inspect.options[:logset] = true + Puppet::Transaction::Report::Rest.any_instance.stubs(:save) + @inspect.setup + end + + it "should retrieve the local catalog" do + Puppet::Resource::Catalog::Yaml.any_instance.expects(:find).with {|request| request.key == Puppet[:certname] }.returns(Puppet::Resource::Catalog.new) + + @inspect.run_command + end + + it "should save the report to REST" do + Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(Puppet::Resource::Catalog.new) + Puppet::Transaction::Report::Rest.any_instance.expects(:save).with {|request| request.instance.host == Puppet[:certname] } + + @inspect.run_command + end + + it "should audit the specified properties" do + catalog = Puppet::Resource::Catalog.new + file = Tempfile.new("foo") + file.puts("file contents") + 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) + + 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["ensure"].should == :file + properties["content"].should == "{md5}#{Digest::MD5.hexdigest("file contents\n")}" + properties.has_key?("target").should == false + end + + it "should set audited to true for all events" do + catalog = Puppet::Resource::Catalog.new + file = Tempfile.new("foo") + resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"}) + 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 + + events.each do |event| + event.audited.should == true + end + 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 + + describe "when archiving to a bucket" do + before :each do + Puppet[:archive_files] = true + Puppet[:archive_file_server] = "filebucketserver" + @catalog = Puppet::Resource::Catalog.new + Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(@catalog) + end + + describe "when auditing files" do + before :each do + @file = tmpfile("foo") + @resource = Puppet::Resource.new(:file, @file, :parameters => {:audit => "content"}) + @catalog.add_resource(@resource) + end + + it "should send an existing file to the file bucket" do + File.open(@file, 'w') { |f| f.write('stuff') } + Puppet::FileBucketFile::Rest.any_instance.expects(:head).with do |request| + request.server == Puppet[:archive_file_server] + end.returns(false) + Puppet::FileBucketFile::Rest.any_instance.expects(:save).with do |request| + request.server == Puppet[:archive_file_server] and request.instance.contents == 'stuff' + end + @inspect.run_command + end + + it "should not send unreadable files" do + File.open(@file, 'w') { |f| f.write('stuff') } + File.chmod(0, @file) + Puppet::FileBucketFile::Rest.any_instance.expects(:head).never + Puppet::FileBucketFile::Rest.any_instance.expects(:save).never + @inspect.run_command + end + + it "should not try to send non-existent files" do + Puppet::FileBucketFile::Rest.any_instance.expects(:head).never + Puppet::FileBucketFile::Rest.any_instance.expects(:save).never + @inspect.run_command + end + + it "should not try to send files whose content we are not auditing" do + @resource[:audit] = "group" + Puppet::FileBucketFile::Rest.any_instance.expects(:head).never + Puppet::FileBucketFile::Rest.any_instance.expects(:save).never + @inspect.run_command + end + + it "should continue if bucketing a file fails" do + File.open(@file, 'w') { |f| f.write('stuff') } + Puppet::FileBucketFile::Rest.any_instance.stubs(:head).returns false + Puppet::FileBucketFile::Rest.any_instance.stubs(:save).raises "failure" + Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| + @report = request.instance + end + + @inspect.run_command + + @report.logs.count.should == 1 + @report.logs.first.message.should =~ /Could not back up/ + end + end + + describe "when auditing non-files" do + before :each do + Puppet::Type.newtype(:stub_type) do + newparam(:name) do + desc "The name var" + isnamevar + end + + newproperty(:content) do + desc "content" + def retrieve + :whatever + end + end + end + + @resource = Puppet::Resource.new(:stub_type, 'foo', :parameters => {:audit => "all"}) + @catalog.add_resource(@resource) + end + + after :each do + Puppet::Type.rmtype(:stub_type) + end + + it "should not try to send non-files" do + Puppet::FileBucketFile::Rest.any_instance.expects(:head).never + Puppet::FileBucketFile::Rest.any_instance.expects(:save).never + @inspect.run_command + end + end + end + + describe "when there are failures" do + before :each do + Puppet::Type.newtype(:stub_type) do + newparam(:name) do + desc "The name var" + isnamevar + end + + newproperty(:content) do + desc "content" + def retrieve + raise "failed" + end + end + end + + @catalog = Puppet::Resource::Catalog.new + Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(@catalog) + + Puppet::Transaction::Report::Rest.any_instance.expects(:save).with do |request| + @report = request.instance + end + end + + after :each do + Puppet::Type.rmtype(:stub_type) + end + + it "should mark the report failed and create failed events for each property" do + @resource = Puppet::Resource.new(:stub_type, 'foo', :parameters => {:audit => "all"}) + @catalog.add_resource(@resource) + + @inspect.run_command + + @report.status.should == "failed" + @report.logs.select{|log| log.message =~ /Could not inspect/}.count.should == 1 + @report.resource_statuses.count.should == 1 + @report.resource_statuses['Stub_type[foo]'].events.count.should == 1 + + event = @report.resource_statuses['Stub_type[foo]'].events.first + event.property.should == "content" + event.status.should == "failure" + event.audited.should == true + event.instance_variables.should_not include("@previous_value") + end + + it "should continue to the next resource" do + @resource = Puppet::Resource.new(:stub_type, 'foo', :parameters => {:audit => "all"}) + @other_resource = Puppet::Resource.new(:stub_type, 'bar', :parameters => {:audit => "all"}) + @catalog.add_resource(@resource) + @catalog.add_resource(@other_resource) + + @inspect.run_command + + @report.resource_statuses.count.should == 2 + @report.resource_statuses.keys.should =~ ['Stub_type[foo]', 'Stub_type[bar]'] + end + end + end + + after :all do + Puppet::Resource::Catalog.indirection.reset_terminus_class + Puppet::Transaction::Report.indirection.terminus_class = :processor + end +end diff --git a/spec/unit/application/kick_spec.rb b/spec/unit/application/kick_spec.rb index dea7ec147..ce0e0c7d0 100755 --- a/spec/unit/application/kick_spec.rb +++ b/spec/unit/application/kick_spec.rb @@ -1,12 +1,10 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(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' @@ -163,7 +161,7 @@ describe Puppet::Application::Kick do @kick.options.stubs(:[]).with(:all).returns(true) @kick.stubs(:puts) - Puppet::Node.expects(:search).with("whatever",:fqdn => :something).returns([]) + Puppet::Node.indirection.expects(:search).with("whatever",:fqdn => :something).returns([]) @kick.setup end @@ -172,7 +170,7 @@ describe Puppet::Application::Kick do @kick.options.stubs(:[]).with(:all).returns(true) @kick.stubs(:puts) - Puppet::Node.expects(:search).with("whatever",:fqdn => nil).returns([]) + Puppet::Node.indirection.expects(:search).with("whatever",:fqdn => nil).returns([]) @kick.setup end @@ -182,7 +180,7 @@ describe Puppet::Application::Kick do @kick.stubs(:puts) @kick.classes = ['class'] - Puppet::Node.expects(:search).with("whatever", :class => "class", :fqdn => nil).returns([]) + Puppet::Node.indirection.expects(:search).with("whatever", :class => "class", :fqdn => nil).returns([]) @kick.setup end @@ -279,7 +277,7 @@ describe Puppet::Application::Kick do end it "should call run on a Puppet::Run for the given host" do - @agent_run.expects(:save).with('https://host:8139/production/run/host').returns(@agent_run) + Puppet::Run.indirection.expects(:save).with(@agent_run, 'https://host:8139/production/run/host').returns(@agent_run) @kick.run_for_host('host') end diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb index e657445a4..1173752d9 100644 --- a/spec/unit/application/master_spec.rb +++ b/spec/unit/application/master_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/master' require 'puppet/daemon' @@ -14,12 +14,13 @@ describe Puppet::Application::Master do Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) - Puppet::Node.stubs(:terminus_class=) - Puppet::Node.stubs(:cache_class=) - Puppet::Node::Facts.stubs(:terminus_class=) - Puppet::Node::Facts.stubs(:cache_class=) - Puppet::Transaction::Report.stubs(:terminus_class=) - Puppet::Resource::Catalog.stubs(:terminus_class=) + Puppet::Node.indirection.stubs(:terminus_class=) + Puppet::Node.indirection.stubs(:cache_class=) + Puppet::Node::Facts.indirection.stubs(:terminus_class=) + Puppet::Node::Facts.indirection.stubs(:cache_class=) + Puppet::Transaction::Report.indirection.stubs(:terminus_class=) + Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) + Puppet::SSL::Host.stubs(:ca_location=) end it "should operate in master run_mode" do @@ -183,7 +184,7 @@ describe Puppet::Application::Master do end it "should cache class in yaml" do - Puppet::Node.expects(:cache_class=).with(:yaml) + Puppet::Node.indirection.expects(:cache_class=).with(:yaml) @master.setup end @@ -298,7 +299,7 @@ describe Puppet::Application::Master do it "should compile a catalog for the specified node" do @master.options[:node] = "foo" - Puppet::Resource::Catalog.expects(:find).with("foo").returns Puppet::Resource::Catalog.new + Puppet::Resource::Catalog.indirection.expects(:find).with("foo").returns Puppet::Resource::Catalog.new $stdout.stubs(:puts) @master.compile @@ -306,7 +307,7 @@ describe Puppet::Application::Master do it "should convert the catalog to a pure-resource catalog and use 'jj' to pretty-print the catalog" do catalog = Puppet::Resource::Catalog.new - Puppet::Resource::Catalog.expects(:find).returns catalog + Puppet::Resource::Catalog.indirection.expects(:find).returns catalog catalog.expects(:to_resource).returns("rescat") @@ -318,7 +319,7 @@ describe Puppet::Application::Master do it "should exit with error code 30 if no catalog can be found" do @master.options[:node] = "foo" - Puppet::Resource::Catalog.expects(:find).returns nil + Puppet::Resource::Catalog.indirection.expects(:find).returns nil @master.expects(:exit).with(30) $stderr.expects(:puts) @@ -327,7 +328,7 @@ describe Puppet::Application::Master do it "should exit with error code 30 if there's a failure" do @master.options[:node] = "foo" - Puppet::Resource::Catalog.expects(:find).raises ArgumentError + Puppet::Resource::Catalog.indirection.expects(:find).raises ArgumentError @master.expects(:exit).with(30) $stderr.expects(:puts) @@ -411,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) diff --git a/spec/unit/application/queue_spec.rb b/spec/unit/application/queue_spec.rb index bd0d53ab1..2ff9001af 100755 --- a/spec/unit/application/queue_spec.rb +++ b/spec/unit/application/queue_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/queue' require 'puppet/indirector/catalog/queue' @@ -13,7 +13,7 @@ describe Puppet::Application::Queue do Puppet::Util::Log.stubs(:newdestination) Puppet::Util::Log.stubs(:level=) - Puppet::Resource::Catalog.stubs(:terminus_class=) + Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) end it "should ask Puppet::Application to parse Puppet configuration file" do @@ -80,7 +80,7 @@ describe Puppet::Application::Queue do @queue.daemon.stubs(:daemonize) Puppet.stubs(:info) Puppet.features.stubs(:stomp?).returns true - Puppet::Resource::Catalog.stubs(:terminus_class=) + Puppet::Resource::Catalog.indirection.stubs(:terminus_class=) Puppet.stubs(:settraps) Puppet.settings.stubs(:print_config?) Puppet.settings.stubs(:print_config) @@ -144,7 +144,7 @@ describe Puppet::Application::Queue do end it "should configure the Catalog class to use ActiveRecord" do - Puppet::Resource::Catalog.expects(:terminus_class=).with(:active_record) + Puppet::Resource::Catalog.indirection.expects(:terminus_class=).with(:active_record) @queue.setup end @@ -171,8 +171,8 @@ describe Puppet::Application::Queue do end it "should log and save each catalog passed by the queue" do - catalog = mock 'catalog', :name => 'eh' - catalog.expects(:save) + catalog = Puppet::Resource::Catalog.new('eh') + Puppet::Resource::Catalog.indirection.expects(:save).with(catalog) Puppet::Resource::Catalog::Queue.expects(:subscribe).yields(catalog) Puppet.expects(:notice).times(2) diff --git a/spec/unit/application/resource_spec.rb b/spec/unit/application/resource_spec.rb index b6c52b11e..3e3f8296b 100755 --- a/spec/unit/application/resource_spec.rb +++ b/spec/unit/application/resource_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/application/resource' @@ -162,21 +162,21 @@ describe Puppet::Application::Resource do @resource.stubs(:puts) @resource.host = 'host' - Puppet::Resource.stubs(:find ).never - Puppet::Resource.stubs(:search).never - Puppet::Resource.stubs(:save ).never + Puppet::Resource.indirection.stubs(:find ).never + Puppet::Resource.indirection.stubs(:search).never + Puppet::Resource.indirection.stubs(:save ).never end it "should search for resources" do @resource.command_line.stubs(:args).returns(['type']) - Puppet::Resource.expects(:search).with('https://host:8139/production/resources/type/', {}).returns([]) + Puppet::Resource.indirection.expects(:search).with('https://host:8139/production/resources/type/', {}).returns([]) @resource.main end it "should describe the given resource" do @resource.command_line.stubs(:args).returns(['type', 'name']) x = stub_everything 'resource' - Puppet::Resource.expects(:find).with('https://host:8139/production/resources/type/name').returns(x) + Puppet::Resource.indirection.expects(:find).with('https://host:8139/production/resources/type/name').returns(x) @resource.main end @@ -184,7 +184,7 @@ describe Puppet::Application::Resource do @resource.command_line.stubs(:args).returns(['type','name','param=temp']) res = stub "resource" - res.expects(:save).with('https://host:8139/production/resources/type/name').returns(res) + Puppet::Resource.indirection.expects(:save).with(res, 'https://host:8139/production/resources/type/name').returns(res) res.expects(:collect) res.expects(:to_manifest) Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(res) @@ -199,20 +199,20 @@ describe Puppet::Application::Resource do @resource.stubs(:puts) @resource.host = nil - Puppet::Resource.stubs(:find ).never - Puppet::Resource.stubs(:search).never - Puppet::Resource.stubs(:save ).never + Puppet::Resource.indirection.stubs(:find ).never + Puppet::Resource.indirection.stubs(:search).never + Puppet::Resource.indirection.stubs(:save ).never end it "should search for resources" do - Puppet::Resource.expects(:search).with('type/', {}).returns([]) + Puppet::Resource.indirection.expects(:search).with('type/', {}).returns([]) @resource.main end it "should describe the given resource" do @resource.command_line.stubs(:args).returns(['type','name']) x = stub_everything 'resource' - Puppet::Resource.expects(:find).with('type/name').returns(x) + Puppet::Resource.indirection.expects(:find).with('type/name').returns(x) @resource.main end @@ -220,7 +220,7 @@ describe Puppet::Application::Resource do @resource.command_line.stubs(:args).returns(['type','name','param=temp']) res = stub "resource" - res.expects(:save).with('type/name').returns(res) + Puppet::Resource.indirection.expects(:save).with(res, 'type/name').returns(res) res.expects(:collect) res.expects(:to_manifest) Puppet::Resource.expects(:new).with('type', 'name', :parameters => {'param' => 'temp'}).returns(res) |
