diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2010-08-05 11:09:25 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-08-21 13:07:19 -0700 |
| commit | 3df0490c9dbc59e27869e09864177536400a5ae3 (patch) | |
| tree | c1aa03afbf81acefa474828c7e4ef9946a09b515 /spec | |
| parent | 5d4f2224a0544d550be0f502fd0defda6697b178 (diff) | |
| download | puppet-3df0490c9dbc59e27869e09864177536400a5ae3.tar.gz puppet-3df0490c9dbc59e27869e09864177536400a5ae3.tar.xz puppet-3df0490c9dbc59e27869e09864177536400a5ae3.zip | |
[#4298] Puppet apply prints an error if the file to apply doesn't exist
Also warns you it's skipping files if you pass it more than one file to
apply.
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Signed-off-by: Matt Robinson <matt@puppetlabs.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/application/apply_spec.rb | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index 0b00d1a2e..8c53136d0 100755 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/application/apply' +require 'puppet/file_bucket/dipper' describe Puppet::Application::Apply do before :each do @@ -53,7 +54,6 @@ describe Puppet::Application::Apply do Puppet.stubs(:trap) Puppet::Log.stubs(:level=) Puppet.stubs(:parse_config) - require 'lib/puppet/file_bucket/dipper' Puppet::FileBucket::Dipper.stubs(:new) STDIN.stubs(:read) @@ -212,7 +212,8 @@ describe Puppet::Application::Apply do @apply.main end - it "should set the manifest if some files are passed on command line" do + it "should set the manifest if a file is passed on command line and the file exists" do + File.stubs(:exist?).with('site.pp').returns true @apply.command_line.stubs(:args).returns(['site.pp']) Puppet.expects(:[]=).with(:manifest,"site.pp") @@ -220,6 +221,23 @@ describe Puppet::Application::Apply do @apply.main end + it "should raise an error if a file is passed on command line and the file does not exist" do + File.stubs(:exist?).with('noexist.pp').returns false + @apply.command_line.stubs(:args).returns(['noexist.pp']) + lambda { @apply.main }.should raise_error(RuntimeError, 'Could not find file noexist.pp') + end + + it "should set the manifest to the first file and warn other files will be skipped" do + File.stubs(:exist?).with('starwarsIV').returns true + File.expects(:exist?).with('starwarsI').never + @apply.command_line.stubs(:args).returns(['starwarsIV', 'starwarsI', 'starwarsII']) + + Puppet.expects(:[]=).with(:manifest,"starwarsIV") + Puppet.expects(:warning).with('Only one file can be applied per run. Skipping starwarsI, starwarsII') + + @apply.main + end + it "should collect the node facts" do Puppet::Node::Facts.expects(:find).returns(@facts) @@ -232,7 +250,7 @@ describe Puppet::Application::Apply do lambda { @apply.main }.should raise_error end - it "should find the node" do + it "should look for the node" do Puppet::Node.expects(:find).returns(@node) @apply.main |
