summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2010-04-12 14:56:09 -0700
committerLuke Kanies <luke@puppetlabs.com>2010-04-12 14:56:09 -0700
commit94fddbc8f746a6062f51e1ab5d24febec3c47f64 (patch)
tree5572148ac3ad8cce7a4c6290f4b986806076e3f1 /test
parent13d141acce03b50f1bfdee2b2a2cba87bcb3da70 (diff)
Fixing and porting Transaction Report tests
There are still a few unported tests, but it's at least better now. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'test')
-rw-r--r--test/lib/puppettest/reporttesting.rb2
-rwxr-xr-xtest/other/report.rb103
2 files changed, 2 insertions, 103 deletions
diff --git a/test/lib/puppettest/reporttesting.rb b/test/lib/puppettest/reporttesting.rb
index 4d88c3cfc..97e32b1c3 100644
--- a/test/lib/puppettest/reporttesting.rb
+++ b/test/lib/puppettest/reporttesting.rb
@@ -7,7 +7,7 @@ module PuppetTest::Reporttesting
# We have to use warning so that the logs always happen
log = Puppet.warning("Report test message %s" % i)
- report.newlog(log)
+ report << log
}
return report
diff --git a/test/other/report.rb b/test/other/report.rb
index 147a0eae7..dd3689432 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -66,20 +66,6 @@ class TestReports < Test::Unit::TestCase
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
-
def test_store_report
# Create a bunch of log messages in an array.
report = Puppet::Transaction::Report.new
@@ -91,7 +77,7 @@ class TestReports < Test::Unit::TestCase
3.times { |i|
log = Puppet.warning("Report test message %s" % i)
- report.newlog(log)
+ report << log
}
assert_nothing_raised do
@@ -146,92 +132,5 @@ class TestReports < Test::Unit::TestCase
else
$stderr.puts "Install RRD for metric reporting tests"
end
-
- def test_tagmail_parsing
- report = Object.new
- report.extend(Puppet::Reports.report(:tagmail))
-
- passers = File.join(datadir, "reports", "tagmail_passers.conf")
- assert(FileTest.exists?(passers), "no passers file %s" % passers)
-
- File.readlines(passers).each do |line|
- assert_nothing_raised("Could not parse %s" % line.inspect) do
- report.parse(line)
- end
- end
-
- # Now make sure the failers fail
- failers = File.join(datadir, "reports", "tagmail_failers.conf")
- assert(FileTest.exists?(failers), "no failers file %s" % failers)
-
- File.readlines(failers).each do |line|
- assert_raise(ArgumentError, "Parsed %s" % line.inspect) do
- report.parse(line)
- end
- end
- end
-
- def test_tagmail_parsing_results
- report = Object.new
- report.extend(Puppet::Reports.report(:tagmail))
- # Now test a few specific lines to make sure we get the results we want
- {
- "tag: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag}, []],
- "tag, other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag other}, []],
- "tag-other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag-other}, []],
- "tag, !other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag}, %w{other}],
- "tag, !other, one, !two: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag one}, %w{other two}],
- "tag: abuse@domain.com, other@domain.com" => [%w{abuse@domain.com other@domain.com}, %w{tag}, []]
-
- }.each do |line, results|
- assert_nothing_raised("Failed to parse %s" % line.inspect) do
- assert_equal(results, report.parse(line).shift, "line %s returned incorrect results %s" % [line.inspect, results.inspect])
- end
- end
- end
-
- def test_tagmail_matching
- report = Puppet::Transaction::Report.new
- Puppet::Util::Log.close
- [%w{one}, %w{one two}, %w{one two three}, %w{one two three four}].each do |tags|
- log = Puppet::Util::Log.new(:level => :notice, :message => tags.join(" "), :tags => tags)
-
- report << log
- end
-
- list = report.logs.collect { |l| l.to_report }
-
- report.extend(Puppet::Reports.report(:tagmail))
-
- {
- [%w{abuse@domain.com}, %w{all}, []] => list,
- [%w{abuse@domain.com}, %w{all}, %w{three}] => list[0..1],
- [%w{abuse@domain.com}, %w{one}, []] => list,
- [%w{abuse@domain.com}, %w{two}, []] => list[1..3],
- [%w{abuse@domain.com}, %w{two}, %w{three}] => list[1..1],
- [%w{abuse@domain.com}, %w{}, %w{one}] => nil
- }.each do |args, expected|
- results = nil
- assert_nothing_raised("Could not match with %s" % args.inspect) do
- results = report.match([args])
- end
-
- if expected
- assert_equal([args[0], expected.join("\n")], results[0], "did get correct results for %s" % args.inspect)
- else
- assert_nil(results[0], "got a report for %s" % args.inspect)
- end
- end
- end
-
- def test_summary
- report = mkreport
-
- summary = report.summary
-
- %w{Changes Total Resources}.each do |main|
- assert(summary.include?(main), "Summary did not include info for %s" % main)
- end
- end
end