diff options
| author | Luke Kanies <luke@madstop.com> | 2007-08-22 18:03:55 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-08-22 18:03:55 -0500 |
| commit | 0682d7e473cfd8f2fe6bee9eae0868b846fd0d50 (patch) | |
| tree | fb66cc4c81e95ee42905410310095b9a8ae23ecc /test/lib | |
| parent | ec50484518425ec8ac36f89b087beb27d5a3d2c8 (diff) | |
| parent | 8b3361afae35cfb65754d7bd9aff5b820ed714f0 (diff) | |
Merge branch 'multi_env'
Diffstat (limited to 'test/lib')
| -rwxr-xr-x | test/lib/puppettest.rb | 2 | ||||
| -rw-r--r-- | test/lib/puppettest/parsertesting.rb | 27 | ||||
| -rw-r--r-- | test/lib/puppettest/railstesting.rb | 8 | ||||
| -rw-r--r-- | test/lib/puppettest/resourcetesting.rb | 46 | ||||
| -rw-r--r-- | test/lib/spec/version.rb | 4 |
5 files changed, 45 insertions, 42 deletions
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 8b85966f5..b56bc563e 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -4,6 +4,7 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))) require 'puppet' +require 'mocha' require 'test/unit' # Yay; hackish but it works @@ -282,6 +283,7 @@ module PuppetTest rescue Timeout::Error # just move on end + mocha_verify if File.stat("/dev/null").mode & 007777 != 0666 File.open("/tmp/nullfailure", "w") { |f| f.puts self.class diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb index d66367ada..3e2930728 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(node, parser) + end + + def mknode(name = nil) + name ||= "nodename" + Puppet::Network::Handler.handler(:node) + Puppet::Network::Handler::Node::SimpleNode.new(name) + end + def mkinterp(args = {}) args[:Code] ||= "" unless args.include?(:Manifest) args[:Local] ||= true @@ -50,14 +65,14 @@ module PuppetTest::ParserTesting end def mkscope(hash = {}) - hash[:interp] ||= mkinterp - hash[:source] ||= (hash[:interp].findclass("", "") || - hash[:interp].newclass("")) + hash[:parser] ||= mkparser + config ||= mkconfig(hash[:parser]) + config.topscope.source = (hash[:parser].findclass("", "") || hash[:parser].newclass("")) - unless hash[:source] + unless config.topscope.source raise "Could not find source for scope" end - Puppet::Parser::Scope.new(hash) + config.topscope end def classobj(name, hash = {}) @@ -293,7 +308,7 @@ module PuppetTest::ParserTesting config = nil assert_nothing_raised { - config = interp.run(Facter["hostname"].value, {}) + config = interp.compile(mknode) } comp = nil diff --git a/test/lib/puppettest/railstesting.rb b/test/lib/puppettest/railstesting.rb index 8b5f074a2..403bdb756 100644 --- a/test/lib/puppettest/railstesting.rb +++ b/test/lib/puppettest/railstesting.rb @@ -40,12 +40,10 @@ module PuppetTest::RailsTesting # Now try storing our crap host = nil + node = mknode(facts["hostname"]) + node.parameters = facts assert_nothing_raised { - host = Puppet::Rails::Host.store( - :resources => resources, - :facts => facts, - :name => facts["hostname"] - ) + host = Puppet::Rails::Host.store(node, resources) } # Now save the whole thing diff --git a/test/lib/puppettest/resourcetesting.rb b/test/lib/puppettest/resourcetesting.rb index 8cb59b83d..e2176d5ef 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] ||= stub :tags => [] {: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) diff --git a/test/lib/spec/version.rb b/test/lib/spec/version.rb index 924d8458a..a0c0fdbbe 100644 --- a/test/lib/spec/version.rb +++ b/test/lib/spec/version.rb @@ -15,7 +15,7 @@ module Spec # RELEASE_CANDIDATE = "RC1"
# RANDOM_TOKEN: 0.375509844656552 - REV = "$LastChangedRevision$".match(/LastChangedRevision: (\d+)/)[1]
+ REV = "LastChangedRevision: 2283".match(/LastChangedRevision: (\d+)/)[1]
STRING = [MAJOR, MINOR, TINY].join('.')
FULL_VERSION = "#{STRING} (r#{REV})"
@@ -27,4 +27,4 @@ module Spec DESCRIPTION = "#{NAME}-#{FULL_VERSION} - BDD for Ruby\n#{URL}"
end
end
-end
\ No newline at end of file +end |
