diff options
| author | Luke Kanies <luke@reductivelabs.com> | 2010-01-30 23:36:32 -0600 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 9c867e6d79dcc56cd34683c9a339dc729ad2d291 (patch) | |
| tree | 27ee2a51648d11891a5168db1e63e064244eeef5 /spec/unit/parser/ast | |
| parent | 274d1c5e78250640b8d2c40201ca2586c0088f32 (diff) | |
| download | puppet-9c867e6d79dcc56cd34683c9a339dc729ad2d291.tar.gz puppet-9c867e6d79dcc56cd34683c9a339dc729ad2d291.tar.xz puppet-9c867e6d79dcc56cd34683c9a339dc729ad2d291.zip | |
Fixing most of the broken tests in test/
This involves a bit of refactoring in the rest
of the code to make it all work, but most of the
changes are fixing or removing old tests.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'spec/unit/parser/ast')
| -rwxr-xr-x | spec/unit/parser/ast/resource.rb | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/spec/unit/parser/ast/resource.rb b/spec/unit/parser/ast/resource.rb index 391f4c770..ef65f4ccd 100755 --- a/spec/unit/parser/ast/resource.rb +++ b/spec/unit/parser/ast/resource.rb @@ -7,7 +7,7 @@ describe Puppet::Parser::AST::Resource do before :each do @title = stub_everything 'title' - @compiler = stub_everything 'compiler' + @compiler = stub_everything 'compiler', :environment => Puppet::Node::Environment.new @scope = Puppet::Parser::Scope.new(:compiler => @compiler) @scope.stubs(:resource).returns(stub_everything) @resource = ast::Resource.new(:title => @title, :type => "Resource", :params => ast::ASTArray.new(:children => []) ) @@ -99,4 +99,38 @@ describe Puppet::Parser::AST::Resource do result[0].should be_virtual result[0].should be_exported end + + # Related to #806, make sure resources always look up the full path to the resource. + describe "when generating qualified resources" do + before do + @scope = Puppet::Parser::Scope.new :compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode")) + @parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new) + @parser.newdefine "one" + @parser.newdefine "one::two" + @parser.newdefine "three" + @twoscope = @scope.newscope(:namespace => "one") + @twoscope.resource = @scope.resource + end + + def resource(type, params = nil) + params ||= Puppet::Parser::AST::ASTArray.new(:children => []) + Puppet::Parser::AST::Resource.new(:type => type, :title => Puppet::Parser::AST::String.new(:value => "myresource"), :params => params) + end + + it "should be able to generate resources with fully qualified type information" do + resource("two").evaluate(@twoscope)[0].type.should == "One::Two" + end + + it "should be able to generate resources with unqualified type information" do + resource("one").evaluate(@twoscope)[0].type.should == "One" + end + + it "should correctly generate resources that can look up builtin types" do + resource("file").evaluate(@twoscope)[0].type.should == "File" + end + + it "should fail for resource types that do not exist" do + lambda { resource("nosuchtype").evaluate(@twoscope) }.should raise_error(Puppet::ParseError) + end + end end |
