summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-06-01 21:30:47 +0000
committerLuke Kanies <luke@madstop.com>2005-06-01 21:30:47 +0000
commitd1f2187c26358288c3a0986b752ffdf5e7b87388 (patch)
treea0a6f988ebc1eb926d25718592aa81d85b7e7d92 /test
parent18d755ac266e15f5c9fb284846df1c7d4c4a1457 (diff)
checksums now work, but not all the way through yet
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@292 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/types/tc_file.rb100
1 files changed, 94 insertions, 6 deletions
diff --git a/test/types/tc_file.rb b/test/types/tc_file.rb
index 9be428eb9..fdc009a16 100644
--- a/test/types/tc_file.rb
+++ b/test/types/tc_file.rb
@@ -17,16 +17,19 @@ class TestFile < Test::Unit::TestCase
@file = nil
@path = File.join($blinkbase,"examples/root/etc/configfile")
Blink[:debug] = 1
+ Blink[:statefile] = "/var/tmp/blinkstate"
assert_nothing_raised() {
- unless Blink::Type::File.has_key?(@path)
- Blink::Type::File.new(
- :path => @path
- )
- end
- @file = Blink::Type::File[@path]
+ @file = Blink::Type::File.new(
+ :path => @path
+ )
}
end
+ def teardown
+ Blink::Type::File.clear
+ system("rm -f %s" % Blink[:statefile])
+ end
+
def test_owner
[Process.uid,%x{whoami}.chomp].each { |user|
assert_nothing_raised() {
@@ -77,6 +80,31 @@ class TestFile < Test::Unit::TestCase
}
end
+ def test_create
+ %w{a b c d}.collect { |name| "/tmp/createst%s" % name }.each { |path|
+ file =nil
+ assert_nothing_raised() {
+ file = Blink::Type::File.new(
+ :path => path,
+ :create => true
+ )
+ }
+ assert_nothing_raised() {
+ file.retrieve
+ }
+ assert_nothing_raised() {
+ file.sync
+ }
+ assert_nothing_raised() {
+ file.retrieve
+ }
+ assert(file.insync?())
+ assert_nothing_raised() {
+ system("rm -f %s" % path)
+ }
+ }
+ end
+
def test_modes
[0644,0755,0777,0641].each { |mode|
assert_nothing_raised() {
@@ -97,4 +125,64 @@ class TestFile < Test::Unit::TestCase
}
}
end
+
+ def test_zchecksums
+ types = %w{md5 md5lite timestamp ctime}
+ files = %w{/tmp/sumtest}
+ types.each { |type|
+ files.each { |path|
+ file = nil
+ events = nil
+ assert_nothing_raised() {
+ File.open(path,"w") { |of|
+ 10.times {
+ of.puts rand(100)
+ }
+ }
+ }
+ # okay, we now know that we have a file...
+ assert_nothing_raised() {
+ file = Blink::Type::File.new(
+ :path => path,
+ :checksum => type
+ )
+ }
+ assert_nothing_raised() {
+ file.retrieve
+ }
+ assert_nothing_raised() {
+ events = file.sync
+ }
+ # we don't want to kick off an event the first time we
+ # come across a file
+ assert(
+ ! events.include?(:file_modified)
+ )
+ assert_nothing_raised() {
+ File.open(path,"w") { |of|
+ 10.times {
+ of.puts rand(100)
+ }
+ }
+ #system("cat %s" % path)
+ }
+ assert_nothing_raised() {
+ file.retrieve
+ }
+ assert_nothing_raised() {
+ events = file.sync
+ }
+ # verify that we're actually getting notified when a file changes
+ assert(
+ events.include?(:file_modified)
+ )
+ assert_nothing_raised() {
+ Blink::Type::File.clear
+ }
+ assert_nothing_raised() {
+ system("rm -f %s" % path)
+ }
+ }
+ }
+ end
end