summaryrefslogtreecommitdiffstats
path: root/test/executables
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-24 21:16:20 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-24 21:16:20 +0000
commit52df47e489d390be9b466da3ef16c2379b9dddba (patch)
treed5006c428e3fae2646a6f60b5e7333dc2da31e87 /test/executables
parentdef15e3de0a488f2f9d75eeb43d04381742609f6 (diff)
downloadpuppet-52df47e489d390be9b466da3ef16c2379b9dddba.tar.gz
puppet-52df47e489d390be9b466da3ef16c2379b9dddba.tar.xz
puppet-52df47e489d390be9b466da3ef16c2379b9dddba.zip
Finalizing the filebucket client, with test code.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2348 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/executables')
-rwxr-xr-xtest/executables/filebucket.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/executables/filebucket.rb b/test/executables/filebucket.rb
new file mode 100755
index 000000000..dbd5fed76
--- /dev/null
+++ b/test/executables/filebucket.rb
@@ -0,0 +1,49 @@
+#!/usr/bin/env ruby
+
+$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
+
+require 'puppet'
+require 'puppet/network/client'
+require 'puppettest'
+require 'socket'
+require 'facter'
+
+class TestPBucket < Test::Unit::TestCase
+ include PuppetTest::ExeTest
+
+ def test_local
+ bucket = tempfile
+ file = tempfile
+ text = "somet ext"
+ md5 = Digest::MD5.hexdigest(text)
+ File.open(file, "w") { |f| f.print text }
+ out = %x{pbucket --bucket #{bucket} backup #{file}}
+
+ outfile, outmd5 = out.chomp.split(": ")
+
+ assert_equal(0, $?, "pbucket did not run successfully")
+
+ assert_equal(file, outfile, "did not output correct file name")
+ assert_equal(md5, outmd5, "did not output correct md5 sum")
+
+ dipper = Puppet::Network::Client.dipper.new(:Path => bucket)
+
+ newtext = nil
+ assert_nothing_raised("Could not get file from bucket") do
+ newtext = dipper.getfile(md5)
+ end
+
+ assert_equal(text, newtext, "did not get correct file from md5 sum")
+
+ out = %x{pbucket --bucket #{bucket} get #{md5}}
+ assert_equal(0, $?, "pbucket did not run successfully")
+ assert_equal(text, out, "did not get correct text back from pbucket")
+
+ File.open(file, "w") { |f| f.puts "some other txt" }
+ out = %x{pbucket --bucket #{bucket} restore #{file} #{md5}}
+ assert_equal(0, $?, "pbucket did not run successfully")
+ assert_equal(text, File.read(file), "file was not restored")
+ end
+end
+
+# $Id$