~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to test/executables/filebucket.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../lib/puppettest'
 
4
 
 
5
require 'puppet'
 
6
require 'puppet/network/client'
 
7
require 'puppettest'
 
8
require 'socket'
 
9
require 'facter'
 
10
 
 
11
class TestFileBucketExe < Test::Unit::TestCase
 
12
    include PuppetTest::ExeTest
 
13
 
 
14
    def test_local
 
15
        bucket = tempfile
 
16
        file = tempfile
 
17
        text = "somet ext"
 
18
        md5 = Digest::MD5.hexdigest(text)
 
19
        File.open(file, "w") { |f| f.print text }
 
20
        out = %x{filebucket --bucket #{bucket} backup #{file}}
 
21
 
 
22
        outfile, outmd5 = out.chomp.split(": ")
 
23
 
 
24
        assert_equal(0, $?, "filebucket did not run successfully")
 
25
 
 
26
        assert_equal(file, outfile, "did not output correct file name")
 
27
        assert_equal(md5, outmd5, "did not output correct md5 sum")
 
28
 
 
29
        dipper = Puppet::Network::Client.dipper.new(:Path => bucket)
 
30
 
 
31
        newtext = nil
 
32
        assert_nothing_raised("Could not get file from bucket") do
 
33
            newtext = dipper.getfile(md5)
 
34
        end
 
35
 
 
36
        assert_equal(text, newtext, "did not get correct file from md5 sum")
 
37
 
 
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")
 
41
 
 
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")
 
46
    end
 
47
end
 
48