diff options
| author | erikh <erikh@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-15 04:00:38 +0000 |
|---|---|---|
| committer | erikh <erikh@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-15 04:00:38 +0000 |
| commit | 4cd37ade1574a326f9ce267af2edc61a78deea86 (patch) | |
| tree | 1093cba18d4c7d7d4170c255db442f3dc0c774a7 /test/lib/support/assertions.rb | |
| parent | 4897995e4cbe4ec3e452de50404799cfc27ed90b (diff) | |
Merged test framework into trunk - still not ready until tests are converted to use it.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1601 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/lib/support/assertions.rb')
| -rw-r--r-- | test/lib/support/assertions.rb | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/lib/support/assertions.rb b/test/lib/support/assertions.rb new file mode 100644 index 000000000..444b0e4ec --- /dev/null +++ b/test/lib/support/assertions.rb @@ -0,0 +1,67 @@ +module PuppetTestSupport + module Assertions + + def assert_rollback_events(events, trans, msg = nil) + run_events(:rollback, events, trans, msg) + end + + def assert_events(events, *items) + trans = nil + comp = nil + msg = nil + + unless events.is_a? Array + raise Puppet::DevError, "Incorrect call of assert_events" + end + if items[-1].is_a? String + msg = items.pop + end + + remove_comp = false + # They either passed a comp or a list of items. + if items[0].is_a? Puppet.type(:component) + comp = items.shift + else + comp = newcomp(items[0].title, *items) + remove_comp = true + end + msg ||= comp.title + assert_nothing_raised("Component %s failed" % [msg]) { + trans = comp.evaluate + } + + run_events(:evaluate, trans, events, msg) + + if remove_comp + Puppet.type(:component).delete(comp) + end + + return trans + end + + # A simpler method that just applies what we have. + def assert_apply(*objects) + if objects[0].is_a?(Puppet.type(:component)) + comp = objects.shift + unless objects.empty? + objects.each { |o| comp.push o } + end + else + comp = newcomp(*objects) + end + trans = nil + + assert_nothing_raised("Failed to create transaction") { + trans = comp.evaluate + } + + events = nil + assert_nothing_raised("Failed to evaluate transaction") { + events = trans.evaluate.collect { |e| e.event } + } + Puppet.type(:component).delete(comp) + events + end + + end +end |
