diff options
| author | Luke Kanies <luke@madstop.com> | 2007-08-20 13:28:40 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-08-20 13:28:40 -0500 |
| commit | 6467c21e15b8a28e627d1395f76fe8f42ee77d70 (patch) | |
| tree | c36f4e350074a028ba6cc9f8e4230284e880ab46 /test/lib | |
| parent | a846ea900f9fa7a2baaa4fbd0742f080e7fd7a04 (diff) | |
| download | puppet-6467c21e15b8a28e627d1395f76fe8f42ee77d70.tar.gz puppet-6467c21e15b8a28e627d1395f76fe8f42ee77d70.tar.xz puppet-6467c21e15b8a28e627d1395f76fe8f42ee77d70.zip | |
The first pass where at least all of the snippet tests pass. I have unfortunately had to stop being so assiduous in my rewriting of tests, but I am in too much of a time crunch to do this "right". The basic structure is definitely in place, though, and from here it is a question of making the rest of the tests work and hopefully writing some sufficient new tests, rather than making the code itself work.
Diffstat (limited to 'test/lib')
| -rw-r--r-- | test/lib/puppettest/parsertesting.rb | 21 | ||||
| -rw-r--r-- | test/lib/puppettest/resourcetesting.rb | 46 |
2 files changed, 35 insertions, 32 deletions
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb index d66367ada..368e112f9 100644 --- a/test/lib/puppettest/parsertesting.rb +++ b/test/lib/puppettest/parsertesting.rb @@ -5,6 +5,8 @@ module PuppetTest::ParserTesting include PuppetTest AST = Puppet::Parser::AST + Config = Puppet::Parser::Configuration + # A fake class that we can use for testing evaluation. class FakeAST attr_writer :evaluate @@ -39,6 +41,19 @@ module PuppetTest::ParserTesting ) end + def mkconfig(parser = nil) + require 'puppet/network/handler/node' + parser ||= mkparser + node = mknode + return Config.new(parser, node) + end + + def mknode(name = nil) + name ||= "nodename" + Puppet::Network::Handler.handler(:node) + Puppet::Network::Handler::Node::SimpleNode.new("nodename") + end + def mkinterp(args = {}) args[:Code] ||= "" unless args.include?(:Manifest) args[:Local] ||= true @@ -50,9 +65,9 @@ module PuppetTest::ParserTesting end def mkscope(hash = {}) - hash[:interp] ||= mkinterp - hash[:source] ||= (hash[:interp].findclass("", "") || - hash[:interp].newclass("")) + hash[:configuration] ||= mkconfig + hash[:parser] ||= mkparser + hash[:source] ||= (hash[:parser].findclass("", "") || hash[:parser].newclass("")) unless hash[:source] raise "Could not find source for scope" diff --git a/test/lib/puppettest/resourcetesting.rb b/test/lib/puppettest/resourcetesting.rb index 8cb59b83d..cbcfb0baf 100644 --- a/test/lib/puppettest/resourcetesting.rb +++ b/test/lib/puppettest/resourcetesting.rb @@ -1,25 +1,25 @@ module PuppetTest::ResourceTesting Parser = Puppet::Parser AST = Puppet::Parser::AST - def mkclassframing(interp = nil) - interp ||= mkinterp + def mkclassframing(parser = nil) + parser ||= mkparser - interp.newdefine("resource", :arguments => [%w{one}, %w{two value}, %w{three}]) - interp.newclass("") - source = interp.newclass("base") - interp.newclass("sub1", :parent => "base") - interp.newclass("sub2", :parent => "base") - interp.newclass("other") + 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") - scope = Parser::Scope.new(:interp => interp) - scope.source = source + config = mkconfig(:parser => parser) + config.topscope.source = source - return interp, scope, source + return parser, config.topscope, source end - def mkevaltest(interp = nil) - interp ||= mkinterp - @interp.newdefine("evaltest", + def mkevaltest(parser = nil) + parser ||= mkparser + @parser.newdefine("evaltest", :arguments => [%w{one}, ["two", stringobj("755")]], :code => resourcedef("file", "/tmp", "owner" => varref("one"), "mode" => varref("two")) @@ -27,26 +27,14 @@ module PuppetTest::ResourceTesting end def mkresource(args = {}) - - if args[:scope] and ! args[:source] - args[:source] = args[:scope].source - end - - unless args[:scope] - unless defined? @scope - raise "Must set @scope to mkresource" - end - end + args[:source] ||= "source" + args[:scope] ||= "scope" {:type => "resource", :title => "testing", - :source => @source, :scope => @scope}.each do |param, value| + :source => "source", :scope => "scope"}.each do |param, value| args[param] ||= value end - unless args[:source].is_a?(Puppet::Parser::AST::HostClass) - args[:source] = args[:scope].findclass(args[:source]) - end - params = args[:params] || {:one => "yay", :three => "rah"} if args[:params] == :none args.delete(:params) |
