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