diff options
| author | Luke Kanies <luke@madstop.com> | 2007-09-04 16:59:30 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-09-04 16:59:30 -0500 |
| commit | b0a947589ea6c7abf5658d9e5038eb7d96a11339 (patch) | |
| tree | 484b6a7ac6f33b23cc022e3b972bde6982e1ff3f /test | |
| parent | 11b127bd6708a18b512ca5b3018ccff1200cc47a (diff) | |
| download | puppet-b0a947589ea6c7abf5658d9e5038eb7d96a11339.tar.gz puppet-b0a947589ea6c7abf5658d9e5038eb7d96a11339.tar.xz puppet-b0a947589ea6c7abf5658d9e5038eb7d96a11339.zip | |
Flipped the switch so that compiles now return a Configuration instance instead of pre-extracting the configuration.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/ast.rb | 10 | ||||
| -rwxr-xr-x | test/language/compile.rb | 7 | ||||
| -rwxr-xr-x | test/language/functions.rb | 16 | ||||
| -rwxr-xr-x | test/language/parser.rb | 2 | ||||
| -rwxr-xr-x | test/language/scope.rb | 8 | ||||
| -rw-r--r-- | test/lib/puppettest/parsertesting.rb | 2 | ||||
| -rw-r--r-- | test/lib/puppettest/resourcetesting.rb | 15 |
7 files changed, 20 insertions, 40 deletions
diff --git a/test/language/ast.rb b/test/language/ast.rb index f62b2340c..dbc1d04ed 100755 --- a/test/language/ast.rb +++ b/test/language/ast.rb @@ -68,7 +68,7 @@ class TestAST < Test::Unit::TestCase # make sure our resourcedefaults ast object works correctly. def test_resourcedefaults - interp, scope, source = mkclassframing + scope = mkscope # Now make some defaults for files args = {:source => "/yay/ness", :group => "yayness"} @@ -166,16 +166,16 @@ class TestAST < Test::Unit::TestCase end def test_virtual_collexp - @interp, @scope, @source = mkclassframing + scope = mkscope # make a resource resource = mkresource(:type => "file", :title => "/tmp/testing", - :params => {:owner => "root", :group => "bin", :mode => "644"}) + :scope => scope, :params => {:owner => "root", :group => "bin", :mode => "644"}) run_collection_queries(:virtual) do |string, result, query| code = nil assert_nothing_raised do - str, code = query.evaluate :scope => @scope + str, code = query.evaluate :scope => scope end assert_instance_of(Proc, code) @@ -186,5 +186,3 @@ class TestAST < Test::Unit::TestCase end end end - -# $Id$ diff --git a/test/language/compile.rb b/test/language/compile.rb index 0d9c9e32a..ceec3c346 100755 --- a/test/language/compile.rb +++ b/test/language/compile.rb @@ -23,7 +23,7 @@ class TestCompile < Test::Unit::TestCase def mkparser # This should mock an interpreter - @parser = mock 'parser' + @parser = stub 'parser', :version => "1.0" end def mkcompile(options = {}) @@ -38,7 +38,7 @@ class TestCompile < Test::Unit::TestCase def test_initialize compile = nil node = stub 'node', :name => "foo" - parser = mock 'parser' + parser = stub 'parser', :version => "1.0" assert_nothing_raised("Could not init compile with all required options") do compile = Compile.new(node, parser) end @@ -150,11 +150,10 @@ class TestCompile < Test::Unit::TestCase # The heart of the action. def test_compile compile = mkcompile - compile.instance_variable_get("@configuration").expects(:extract).returns(:config) [:set_node_parameters, :evaluate_main, :evaluate_ast_node, :evaluate_node_classes, :evaluate_generators, :fail_on_unevaluated, :finish].each do |method| compile.expects(method) end - assert_equal(:config, compile.compile, "Did not return the results of the extraction") + assert_instance_of(Puppet::Node::Configuration, compile.compile, "Did not return the configuration") end # Test setting the node's parameters into the top scope. diff --git a/test/language/functions.rb b/test/language/functions.rb index efa506218..395577cb6 100755 --- a/test/language/functions.rb +++ b/test/language/functions.rb @@ -213,14 +213,15 @@ class TestLangFunctions < Test::Unit::TestCase Puppet[:environment] = "yay" - version = interp.compile(node) - - objects = nil + configuration = nil assert_nothing_raised { - objects = interp.compile(node) + configuration = interp.compile(node) } - fileobj = objects[0] + version = configuration.version + + fileobj = configuration.vertices.find { |r| r.title == file } + assert(fileobj, "File was not in configuration") assert_equal("original text\n", fileobj["content"], "Template did not work") @@ -234,10 +235,7 @@ class TestLangFunctions < Test::Unit::TestCase f.puts "new text" end - assert_nothing_raised { - objects = interp.compile(node) - } - newversion = interp.compile(node) + newversion = interp.compile(node).version assert(version != newversion, "Parse date did not change") end diff --git a/test/language/parser.rb b/test/language/parser.rb index 36e058b11..ddf35e3e3 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -622,7 +622,7 @@ file { "/tmp/yayness": code = nil assert_nothing_raised do - code = interp.compile(mknode).flatten + code = interp.compile(mknode).extract.flatten end assert(code.length == 1, "Did not get the file") assert_instance_of(Puppet::TransObject, code[0]) diff --git a/test/language/scope.rb b/test/language/scope.rb index 213226241..b317fa4c8 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -419,17 +419,17 @@ Host <<||>>" ) } - objects = nil + config = nil # We run it twice because we want to make sure there's no conflict # if we pull it up from the database. node = mknode node.parameters = {"hostname" => node.name} 2.times { |i| assert_nothing_raised { - objects = interp.compile(node) + config = interp.compile(node) } - flat = objects.flatten + flat = config.extract.flatten %w{puppet myhost}.each do |name| assert(flat.find{|o| o.name == name }, "Did not find #{name}") @@ -441,7 +441,7 @@ Host <<||>>" end def test_namespaces - parser, scope, source = mkclassframing + scope = mkscope assert_equal([""], scope.namespaces, "Started out with incorrect namespaces") diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb index 9e90bbdd6..b8fd8bd83 100644 --- a/test/lib/puppettest/parsertesting.rb +++ b/test/lib/puppettest/parsertesting.rb @@ -316,7 +316,7 @@ module PuppetTest::ParserTesting comp = nil assert_nothing_raised { - comp = config.to_type + comp = config.extract.to_type } assert_apply(comp) diff --git a/test/lib/puppettest/resourcetesting.rb b/test/lib/puppettest/resourcetesting.rb index 54154d504..325602c22 100644 --- a/test/lib/puppettest/resourcetesting.rb +++ b/test/lib/puppettest/resourcetesting.rb @@ -1,21 +1,6 @@ module PuppetTest::ResourceTesting Parser = Puppet::Parser AST = Puppet::Parser::AST - def mkclassframing(parser = nil) - parser ||= mkparser - - parser.newdefine("resource", :arguments => [%w{one}, %w{two value}, %w{three}]) - parser.newclass("") - source = parser.newclass("base") - parser.newclass("sub1", :parent => "base") - parser.newclass("sub2", :parent => "base") - parser.newclass("other") - - config = mkconfig(:parser => parser) - config.topscope.source = source - - return parser, config.topscope, source - end def mkevaltest(parser = nil) parser ||= mkparser |
