diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 04:52:34 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-13 04:52:34 +0000 |
| commit | 5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6 (patch) | |
| tree | 7d6cadbf16f19cab8d3c89db3a4b95161241c88b /test | |
| parent | 0819e35be74bc997c3a953f05bab874b8d76429d (diff) | |
| download | puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.tar.gz puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.tar.xz puppet-5863a0336e1f3bd5e1be85676bb0e7ac7337f2e6.zip | |
Adding initial rails support. One can now store host configurations using ActiveRecord into a database (I have only tested sqlite3). Tomorrow will be the grammars used to retrieve those records for object collection.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1187 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/language/interpreter.rb | 30 | ||||
| -rwxr-xr-x | test/language/rails.rb | 81 | ||||
| -rw-r--r-- | test/puppettest.rb | 2 |
3 files changed, 112 insertions, 1 deletions
diff --git a/test/language/interpreter.rb b/test/language/interpreter.rb index 641a5d0c9..4b1852682 100755 --- a/test/language/interpreter.rb +++ b/test/language/interpreter.rb @@ -71,6 +71,36 @@ class TestInterpreter < Test::Unit::TestCase assert(config != newconfig, "Configs are somehow the same") end + def test_hoststorage + assert_nothing_raised { + Puppet[:storeconfigs] = true + } + + file = tempfile() + File.open(file, "w") { |f| + f.puts "file { \"/etc\": owner => root }" + } + + interp = nil + assert_nothing_raised { + interp = Puppet::Parser::Interpreter.new( + :Manifest => file, + :UseNodes => false + ) + } + + facts = {} + Facter.each { |fact, val| facts[fact] = val } + + objects = nil + assert_nothing_raised { + objects = interp.run(facts["hostname"], facts) + } + + obj = Puppet::Rails::Host.find_by_name(facts["hostname"]) + assert(obj, "Could not find host object") + end + if Facter["domain"].value == "madstop.com" begin require 'ldap' diff --git a/test/language/rails.rb b/test/language/rails.rb new file mode 100755 index 000000000..144faece2 --- /dev/null +++ b/test/language/rails.rb @@ -0,0 +1,81 @@ +#!/usr/bin/ruby + +if __FILE__ == $0 + $:.unshift '../../lib' + $:.unshift '..' + $puppetbase = "../.." +end + +require 'puppet' +require 'puppet/parser/interpreter' +require 'puppet/parser/parser' +require 'puppet/client' +require 'test/unit' +require 'puppettest' + +class TestRails < Test::Unit::TestCase + include ParserTesting + + def test_includerails + assert_nothing_raised { + require 'puppet/rails' + } + end + + # Don't do any tests w/out this class + if defined? ActiveRecord::Base + def test_hostcache + # First make some objects + object = Puppet::TransObject.new("/tmp", "file") + object.tags = %w{testing puppet} + object[:mode] = "1777" + object[:owner] = "root" + + bucket = Puppet::TransBucket.new + bucket.push object + + # Now collect our facts + facts = {} + Facter.each do |fact, value| facts[fact] = value end + + assert_nothing_raised { + Puppet::Rails.init + } + + # Now try storing our crap + host = nil + assert_nothing_raised { + host = Puppet::Rails::Host.store( + :objects => bucket, + :facts => facts, + :host => facts["hostname"] + ) + } + + assert(host, "Did not create host") + + obj = nil + assert_nothing_raised { + obj = Puppet::Rails::Host.find_by_name(facts["hostname"]) + } + assert(obj, "Could not find host object") + + assert(obj.rails_objects, "No objects on host") + + assert_equal(facts["hostname"], obj.facts["hostname"], + "Did not retrieve facts") + end + + def test_railsinit + assert_nothing_raised { + Puppet::Rails.init + } + + assert(FileTest.exists?(Puppet[:dblocation]), "Database does not exist") + end + else + $stderr.puts "Install Rails for Rails and Caching tests" + end +end + +# $Id$ diff --git a/test/puppettest.rb b/test/puppettest.rb index d0c7a5778..f9014245a 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -59,7 +59,7 @@ module TestPuppet if $0 =~ /.+\.rb/ or Puppet[:debug] Puppet::Log.newdestination :console Puppet::Log.level = :debug - $VERBOSE = 1 + #$VERBOSE = 1 else Puppet::Log.close Puppet::Log.newdestination tempfile() |
