diff options
author | Luke Kanies <luke@reductivelabs.com> | 2010-01-31 13:40:33 -0800 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | 6e4db8261af6372c6acad4e8ff3f7a32e7a074fb (patch) | |
tree | 7f8cf664948dcbe4bd192a0b9cdd80755c3eb336 /test | |
parent | aa659f27aaa40507cb1199df048fb85b2c586944 (diff) | |
download | puppet-6e4db8261af6372c6acad4e8ff3f7a32e7a074fb.tar.gz puppet-6e4db8261af6372c6acad4e8ff3f7a32e7a074fb.tar.xz puppet-6e4db8261af6372c6acad4e8ff3f7a32e7a074fb.zip |
Fixing type/title resource resolution
This code is impressively difficult, because
sometimes resource types act like resources (classes
and nodes are singletons) and sometimes like resource
types (defined and builtin resources).
So, to get nodes to show as Node[foo] and classes as
Class[Foo::Bar], but defined resources to show up as
Foo::Bar[baz], we have to do some silliness.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'test')
-rwxr-xr-x | test/language/ast/resource_reference.rb | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/test/language/ast/resource_reference.rb b/test/language/ast/resource_reference.rb deleted file mode 100755 index 5abb0d6e5..000000000 --- a/test/language/ast/resource_reference.rb +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2007-07-8. -# Copyright (c) 2007. All rights reserved. - -require File.dirname(__FILE__) + '/../../lib/puppettest' - -require 'puppettest' -require 'puppettest/parsertesting' - -class TestASTResourceReference < Test::Unit::TestCase - include PuppetTest - include PuppetTest::ParserTesting - AST = Puppet::Parser::AST - - def newref(type, title) - AST::ResourceReference.new(:type => type, :title => AST::String.new(:value => title)) - end - - def setup - super - @scope = mkscope - @parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new) - end - - # Related to #706, make sure resource references correctly translate to qualified types. - def test_scoped_references - @parser.newdefine "one" - @parser.newdefine "one::two" - @parser.newdefine "three" - twoscope = @scope.newscope(:namespace => "one") - assert(twoscope.find_definition("two"), "Could not find 'two' definition") - title = "title" - - # First try a qualified type - assert_equal("One::Two", newref("two", title).evaluate(twoscope).type, - "Defined type was not made fully qualified") - - # Then try a type that does not need to be qualified - assert_equal("One", newref("one", title).evaluate(twoscope).type, - "Unqualified defined type was not handled correctly") - - # Then an unqualified type from within the one namespace - assert_equal("Three", newref("three", title).evaluate(twoscope).type, - "Defined type was not made fully qualified") - - # Then a builtin type - assert_equal("File", newref("file", title).evaluate(twoscope).type, - "Builtin type was not handled correctly") - - # Now try a type that does not exist, which should throw an error. - assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do - newref("nosuchtype", title).evaluate(twoscope) - end - - # Now run the same tests, but with the classes - @parser.newclass "four" - @parser.newclass "one::five" - - # First try an unqualified type - assert_equal("four", newref("class", "four").evaluate(twoscope).title, - "Unqualified class was not found") - - # Then a qualified class - assert_equal("one::five", newref("class", "five").evaluate(twoscope).title, - "Class was not made fully qualified") - - # Then try a type that does not need to be qualified - assert_equal("four", newref("class", "four").evaluate(twoscope).title, - "Unqualified class was not handled correctly") - - # Now try a type that does not exist, which should throw an error. - assert_raise(Puppet::ParseError, "Did not fail on a missing type in a resource reference") do - newref("class", "nosuchclass").evaluate(twoscope) - end - end -end |