3
require File.dirname(__FILE__) + '/../lib/puppettest'
6
require 'puppet/network/client'
11
class TestFileBucketExe < Test::Unit::TestCase
12
include PuppetTest::ExeTest
18
md5 = Digest::MD5.hexdigest(text)
19
File.open(file, "w") { |f| f.print text }
20
out = %x{filebucket --bucket #{bucket} backup #{file}}
22
outfile, outmd5 = out.chomp.split(": ")
24
assert_equal(0, $?, "filebucket did not run successfully")
26
assert_equal(file, outfile, "did not output correct file name")
27
assert_equal(md5, outmd5, "did not output correct md5 sum")
29
dipper = Puppet::Network::Client.dipper.new(:Path => bucket)
32
assert_nothing_raised("Could not get file from bucket") do
33
newtext = dipper.getfile(md5)
36
assert_equal(text, newtext, "did not get correct file from md5 sum")
38
out = %x{filebucket --bucket #{bucket} get #{md5}}
39
assert_equal(0, $?, "filebucket did not run successfully")
40
assert_equal(text, out, "did not get correct text back from filebucket")
42
File.open(file, "w") { |f| f.puts "some other txt" }
43
out = %x{filebucket --bucket #{bucket} restore #{file} #{md5}}
44
assert_equal(0, $?, "filebucket did not run successfully")
45
assert_equal(text, File.read(file), "file was not restored")