diff options
Diffstat (limited to 'test/executables')
| -rwxr-xr-x | test/executables/filebucket.rb | 49 |
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$ |
