summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 20:46:07 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 20:46:07 +0000
commit24f07e0686cc9d81452d33daf215fa050ec89129 (patch)
tree50bb812a7b31b91af44073ca0f2dba807ec4d72b
parentdea7e24423adbb8bc0839dedcf1157d6dff6a91b (diff)
downloadpuppet-24f07e0686cc9d81452d33daf215fa050ec89129.tar.gz
puppet-24f07e0686cc9d81452d33daf215fa050ec89129.tar.xz
puppet-24f07e0686cc9d81452d33daf215fa050ec89129.zip
committing tests for previous changes
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1349 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xtest/other/report.rb64
-rwxr-xr-xtest/other/storage.rb2
-rw-r--r--test/other/transactions.rb19
3 files changed, 81 insertions, 4 deletions
diff --git a/test/other/report.rb b/test/other/report.rb
new file mode 100755
index 000000000..8d6f8541c
--- /dev/null
+++ b/test/other/report.rb
@@ -0,0 +1,64 @@
+if __FILE__ == $0
+ $:.unshift '..'
+ $:.unshift '../../lib'
+ $puppetbase = "../.."
+end
+
+require 'puppet'
+require 'puppet/transaction/report'
+require 'puppettest'
+require 'test/unit'
+
+class TestReports < Test::Unit::TestCase
+ include TestPuppet
+
+ # Make sure we can use reports as log destinations.
+ def test_reports_as_log_destinations
+ report = nil
+ assert_nothing_raised {
+ report = Puppet::Transaction::Report.new
+ }
+
+ assert_nothing_raised {
+ Puppet::Log.newdestination(report)
+ }
+
+ # Now make a file for testing logging
+ file = Puppet::Type.newfile(:path => tempfile(), :ensure => "file")
+
+ log = nil
+ assert_nothing_raised {
+ log = file.log "This is a message, yo"
+ }
+
+ assert(report.logs.include?(log), "Report did not get log message")
+
+ log = Puppet.info "This is a non-sourced message"
+
+ assert(! report.logs.include?(log), "Report got log message")
+
+ assert_nothing_raised {
+ Puppet::Log.close(report)
+ }
+
+ log = file.log "This is another message, yo"
+
+ assert(! report.logs.include?(log), "Report got log message after close")
+ end
+
+ def test_newmetric
+ report = nil
+ assert_nothing_raised {
+ report = Puppet::Transaction::Report.new
+ }
+
+ assert_nothing_raised {
+ report.newmetric(:mymetric,
+ :total => 12,
+ :done => 6
+ )
+ }
+ end
+end
+
+# $Id$
diff --git a/test/other/storage.rb b/test/other/storage.rb
index fc9b52cd6..64fddf332 100755
--- a/test/other/storage.rb
+++ b/test/other/storage.rb
@@ -8,7 +8,7 @@ require 'puppet'
require 'puppettest'
require 'test/unit'
-class TestParsedFile < Test::Unit::TestCase
+class TestStorage < Test::Unit::TestCase
include TestPuppet
def mkfile
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index cfb00eaeb..1c175b368 100644
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -38,12 +38,25 @@ class TestTransactions < Test::Unit::TestCase
report = trans.report
}
- assert_equal(2, report.length,
- "Did not get the right number of log messages back")
+ # First test the report logs
+ assert(report.logs.length > 0, "Did not get any report logs")
- report.each do |obj|
+ report.logs.each do |obj|
assert_instance_of(Puppet::Log, obj)
end
+
+ # Then test the metrics
+ metrics = report.metrics
+
+ assert(metrics, "Did not get any metrics")
+ assert(metrics.length > 0, "Did not get any metrics")
+
+ assert(metrics.include?(:objects), "Did not get object metrics")
+ assert(metrics.include?(:changes), "Did not get change metrics")
+
+ metrics.each do |name, metric|
+ assert_instance_of(Puppet::Metric, metric)
+ end
end
unless %x{groups}.chomp.split(/ /).length > 1