summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-09 18:45:51 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-09 18:45:51 +0000
commit2dbd7e19de0caa683f7e0b4da5654eb15bc419da (patch)
tree298ac3b9f49804e32fd135842bae38de3b5d4b46 /test
parent7756f9a57fa83e811888298edd339978bb6a9c83 (diff)
downloadpuppet-2dbd7e19de0caa683f7e0b4da5654eb15bc419da.tar.gz
puppet-2dbd7e19de0caa683f7e0b4da5654eb15bc419da.tar.xz
puppet-2dbd7e19de0caa683f7e0b4da5654eb15bc419da.zip
Fixing #96. Defaults are now set when the object is passed out by the scope, rather than when the object is created. This is nice because it also moves awareness of the scope internals out of the AST object and back into the scope.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@996 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/scope.rb31
-rw-r--r--test/puppettest.rb36
2 files changed, 67 insertions, 0 deletions
diff --git a/test/language/scope.rb b/test/language/scope.rb
index a18b75bff..9c5302988 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -513,4 +513,35 @@ class TestScope < Test::Unit::TestCase
# trans = scope.evaluate(:ast => top)
#}
end
+
+ def test_defaultswithmultiplestatements
+ path = tempfile()
+
+ stats = []
+ stats << defaultobj("file", "group" => "root")
+ stats << fileobj(path, "owner" => "root")
+ stats << fileobj(path, "mode" => "755")
+
+ top = AST::ASTArray.new(
+ :file => __FILE__,
+ :line => __LINE__,
+ :children => stats
+ )
+ scope = Puppet::Parser::Scope.new()
+ assert_nothing_raised {
+ scope.evaluate(:ast => top)
+ }
+
+ trans = nil
+ assert_nothing_raised {
+ trans = scope.to_trans
+ }
+
+ obj = trans.find do |obj| obj.is_a? Puppet::TransObject end
+
+ assert(obj, "Could not retrieve file obj")
+ assert_equal("root", obj["group"], "Default did not take")
+ assert_equal("root", obj["owner"], "Owner did not take")
+ assert_equal("755", obj["mode"], "Mode did not take")
+ end
end
diff --git a/test/puppettest.rb b/test/puppettest.rb
index a16f4d80b..a8af679fb 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -766,6 +766,16 @@ module ParserTesting
}
end
+ def typeobj(name)
+ assert_nothing_raised("Could not create type %s" % name) {
+ return AST::Type.new(
+ :file => tempfile(),
+ :line => rand(100),
+ :value => name
+ )
+ }
+ end
+
def nodeobj(name)
assert_nothing_raised("Could not create node %s" % name) {
return AST::NodeDef.new(
@@ -832,6 +842,32 @@ module ParserTesting
)
}
end
+
+ def defaultobj(type, params)
+ pary = []
+ params.each { |p,v|
+ pary << AST::ObjectParam.new(
+ :file => __FILE__,
+ :line => __LINE__,
+ :param => nameobj(p),
+ :value => stringobj(v)
+ )
+ }
+ past = AST::ASTArray.new(
+ :file => __FILE__,
+ :line => __LINE__,
+ :children => pary
+ )
+
+ assert_nothing_raised("Could not create defaults for %s" % type) {
+ return AST::TypeDefaults.new(
+ :file => __FILE__,
+ :line => __LINE__,
+ :type => typeobj(type),
+ :params => past
+ )
+ }
+ end
end
class PuppetTestSuite