summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-05-30 01:36:48 +0000
committerLuke Kanies <luke@madstop.com>2005-05-30 01:36:48 +0000
commit2b97b479688e987a8d9e663fd926108e7c02e7e4 (patch)
tree268177c182c37a118bae0497812dca0b345a08b2 /test
parentb46135f84cefbc28d41dc6c4da42b93e08da8648 (diff)
there are now explicit tests for transactions, including rollback, and more tests involving querying
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@282 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/other/tc_transactions.rb141
-rw-r--r--test/types/tc_query.rb10
2 files changed, 150 insertions, 1 deletions
diff --git a/test/other/tc_transactions.rb b/test/other/tc_transactions.rb
new file mode 100644
index 000000000..48d0028b5
--- /dev/null
+++ b/test/other/tc_transactions.rb
@@ -0,0 +1,141 @@
+if __FILE__ == $0
+ $:.unshift '..'
+ $:.unshift '../../lib'
+ $blinkbase = "../../../../language/trunk"
+end
+
+require 'blink'
+require 'test/unit'
+
+# $Id$
+
+class TestTransactions < Test::Unit::TestCase
+ def setup
+ Blink[:debug] = true
+
+ @groups = %x{groups}.chomp.split(/ /)
+ unless @groups.length > 1
+ p @groups
+ raise "You must be a member of more than one group to test this"
+ end
+ end
+
+ def teardown
+ assert_nothing_raised() {
+ Blink::Type.allclear
+ }
+ end
+
+ def newfile
+ assert_nothing_raised() {
+ cfile = File.join($blinkbase,"examples/root/etc/configfile")
+ unless Blink::Type::File.has_key?(cfile)
+ Blink::Type::File.new(
+ :path => cfile,
+ :check => [:mode, :owner, :group]
+ )
+ end
+ return Blink::Type::File[cfile]
+ }
+ end
+
+ def newservice
+ assert_nothing_raised() {
+ unless Blink::Type::Service.has_key?("sleeper")
+ Blink::Type::Service.new(
+ :name => "sleeper",
+ :check => [:running]
+ )
+ Blink::Type::Service.setpath(
+ File.join($blinkbase,"examples/root/etc/init.d")
+ )
+ end
+ return Blink::Type::Service["sleeper"]
+ }
+ end
+
+ def newcomp(*args)
+ comp = nil
+ assert_nothing_raised() {
+ comp = Blink::Component.new
+ }
+
+ args.each { |arg|
+ assert_nothing_raised() {
+ comp.push arg
+ }
+ }
+
+ return comp
+ end
+
+ def test_filetrans
+ transaction = nil
+ file = newfile()
+ states = {}
+ check = [:group,:mode]
+ file[:check] = check
+
+ assert_nothing_raised() {
+ file.retrieve
+ }
+
+ check.each { |state|
+ states[state] = file[state]
+ }
+
+ component = newcomp(file)
+ assert_nothing_raised() {
+ file[:group] = @groups[1]
+ file[:mode] = "755"
+ }
+ assert_nothing_raised() {
+ transaction = component.evaluate
+ }
+ assert_nothing_raised() {
+ transaction.evaluate
+ }
+ assert_nothing_raised() {
+ transaction.rollback
+ }
+ assert_nothing_raised() {
+ file.retrieve
+ }
+ states.each { |state,value|
+ assert_equal(
+ value,file[state]
+ )
+ }
+ end
+
+ def test_servicetrans
+ transaction = nil
+ service = newservice
+ service[:check] = [:running]
+
+ component = newcomp(service)
+
+ assert_nothing_raised() {
+ service.retrieve
+ }
+ state = service[:running]
+ assert_nothing_raised() {
+ service[:running] = 1
+ }
+ assert_nothing_raised() {
+ transaction = component.evaluate
+ }
+ assert_nothing_raised() {
+ transaction.evaluate
+ }
+ assert_nothing_raised() {
+ service[:running] = 0
+ }
+ assert_nothing_raised() {
+ transaction = component.evaluate
+ }
+ assert_nothing_raised() {
+ transaction.evaluate
+ }
+ end
+end
diff --git a/test/types/tc_query.rb b/test/types/tc_query.rb
index 39c61c8c8..9b18b86ac 100644
--- a/test/types/tc_query.rb
+++ b/test/types/tc_query.rb
@@ -23,7 +23,7 @@ class TestBasic < Test::Unit::TestCase
unless Blink::Type::File.has_key?(cfile)
Blink::Type::File.new(
:path => cfile,
- :check => [:mode, :owner, :group]
+ :check => [:mode, :owner]
)
end
@configfile = Blink::Type::File[cfile]
@@ -72,6 +72,14 @@ class TestBasic < Test::Unit::TestCase
assert_nothing_raised() {
yayfile.retrieve
}
+
+ assert_nothing_raised() {
+ yayfile[:check] = :group
+ }
+
+ assert_nothing_raised() {
+ yayfile.retrieve
+ }
end
def test_service