summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-08-27 12:49:54 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-08-27 12:50:26 -0700
commit21afb51a1b84116b2a906a6959ae588f45135104 (patch)
tree48fa0438d0a50202194956344d0cf1f10b17b818 /spec/unit
parent1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac (diff)
parent8be1929043f4560bb17a4b06293b3f9a4efcfdbf (diff)
downloadpuppet-21afb51a1b84116b2a906a6959ae588f45135104.tar.gz
puppet-21afb51a1b84116b2a906a6959ae588f45135104.tar.xz
puppet-21afb51a1b84116b2a906a6959ae588f45135104.zip
Merge commit '2.6.1rc3'
This synchronizes the 2.7 master branch with 2.6.1RC3 The 2.7 next branch has now diverged from master for the first time, as if contains code that has not reached "release quality" status.
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/application/apply_spec.rb24
-rwxr-xr-xspec/unit/application/doc_spec.rb19
-rwxr-xr-xspec/unit/indirector/yaml_spec.rb24
-rwxr-xr-xspec/unit/parser/compiler_spec.rb13
-rwxr-xr-xspec/unit/resource/type_spec.rb17
5 files changed, 68 insertions, 29 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
diff --git a/spec/unit/application/doc_spec.rb b/spec/unit/application/doc_spec.rb
index 7a22f5b2e..55da5e39a 100755
--- a/spec/unit/application/doc_spec.rb
+++ b/spec/unit/application/doc_spec.rb
@@ -27,10 +27,6 @@ describe Puppet::Application::Doc do
@doc.should respond_to(:rdoc)
end
- it "should declare a trac command" do
- @doc.should respond_to(:trac)
- end
-
it "should declare a fallback for unknown options" do
@doc.should respond_to(:handle_unknown)
end
@@ -270,21 +266,6 @@ describe Puppet::Application::Doc do
end
describe "when running" do
- before :each do
- end
-
- describe "in trac mode" do
- it "should call trac for each reference" do
- ref = stub 'ref'
- Puppet::Util::Reference.stubs(:reference).with(:ref).returns(ref)
- @doc.options.stubs(:[]).with(:references).returns([:ref])
- @doc.options.stubs(:[]).with(:mode).returns(:trac)
-
- ref.expects(:trac)
-
- @doc.trac
- end
- end
describe "in rdoc mode" do
before :each do
diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb
index 134d476ba..86c13c5a0 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -40,6 +40,18 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
@store.path(:me).should =~ %r{^/client/yaml/dir}
end
+ it "should use the extension if one is specified" do
+ Puppet.run_mode.expects(:master?).returns true
+ Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir"
+ @store.path(:me,'.farfignewton').should =~ %r{\.farfignewton$}
+ end
+
+ it "should assume an extension of .yaml if none is specified" do
+ Puppet.run_mode.expects(:master?).returns true
+ Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir"
+ @store.path(:me).should =~ %r{\.yaml$}
+ end
+
it "should store all files in a single file root set in the Puppet defaults" do
@store.path(:me).should =~ %r{^#{@dir}}
end
@@ -120,8 +132,8 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
@request = stub 'request', :key => "*", :instance => @subject
@one = mock 'one'
@two = mock 'two'
- @store.expects(:base).returns "/my/yaml/dir"
- Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml two.yaml})
+ @store.expects(:path).with(@request.key,'').returns :glob
+ Dir.expects(:glob).with(:glob).returns(%w{one.yaml two.yaml})
YAML.expects(:load_file).with("one.yaml").returns @one;
YAML.expects(:load_file).with("two.yaml").returns @two;
@store.search(@request).should == [@one, @two]
@@ -130,16 +142,16 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
it "should return an array containing a single instance of fact when globbing 'one*'" do
@request = stub 'request', :key => "one*", :instance => @subject
@one = mock 'one'
- @store.expects(:base).returns "/my/yaml/dir"
- Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml})
+ @store.expects(:path).with(@request.key,'').returns :glob
+ Dir.expects(:glob).with(:glob).returns(%w{one.yaml})
YAML.expects(:load_file).with("one.yaml").returns @one;
@store.search(@request).should == [@one]
end
it "should return an empty array when the glob doesn't match anything" do
@request = stub 'request', :key => "f*ilglobcanfail*", :instance => @subject
- @store.expects(:base).returns "/my/yaml/dir"
- Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns([])
+ @store.expects(:path).with(@request.key,'').returns :glob
+ Dir.expects(:glob).with(:glob).returns []
@store.search(@request).should == []
end
end
diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb
index e8c06dd0b..22d52f257 100755
--- a/spec/unit/parser/compiler_spec.rb
+++ b/spec/unit/parser/compiler_spec.rb
@@ -430,7 +430,18 @@ describe Puppet::Parser::Compiler do
lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError)
end
- it "should add edges from the class resources to the main stage if no stage is specified" do
+ it "should add edges from the class resources to the parent's stage if no stage is specified" do
+ main = @compiler.catalog.resource(:stage, :main)
+ foo_stage = resource(:stage, :foo_stage)
+ @compiler.add_resource(@scope, foo_stage)
+ resource = resource(:class, "foo")
+ @scope.stubs(:resource).returns(:stage => :foo_stage)
+ @compiler.add_resource(@scope, resource)
+
+ @compiler.catalog.should be_edge(foo_stage, resource)
+ end
+
+ it "should add edges from top-level class resources to the main stage if no stage is specified" do
main = @compiler.catalog.resource(:stage, :main)
resource = resource(:class, "foo")
@compiler.add_resource(@scope, resource)
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb
index 4d3942c5c..f58092ec5 100755
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@ -412,6 +412,23 @@ describe Puppet::Resource::Type do
@type = Puppet::Resource::Type.new(:hostclass, "foo")
end
+ it "should add hostclass names to the classes list" do
+ @type.evaluate_code(@resource)
+ @compiler.catalog.classes.should be_include("foo")
+ end
+
+ it "should add node names to the classes list" do
+ @type = Puppet::Resource::Type.new(:node, "foo")
+ @type.evaluate_code(@resource)
+ @compiler.catalog.classes.should be_include("foo")
+ end
+
+ it "should not add defined resource names to the classes list" do
+ @type = Puppet::Resource::Type.new(:definition, "foo")
+ @type.evaluate_code(@resource)
+ @compiler.catalog.classes.should_not be_include("foo")
+ end
+
it "should set all of its parameters in a subscope" do
subscope = stub 'subscope', :compiler => @compiler
@type.expects(:subscope).with(@scope, @resource).returns subscope