~nvalcarcel/ubuntu/lucid/puppet/fix-546677

« back to all changes in this revision

Viewing changes to test/executables/filebucket.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

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
 
        basedir = tempfile()
16
 
        FileUtils.mkdir_p(basedir)
17
 
 
18
 
        bucket = tempfile
19
 
        file = tempfile
20
 
        text = "somet ext"
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}}
24
 
 
25
 
        outfile, outmd5 = out.chomp.split(": ")
26
 
 
27
 
        assert_equal(0, $?, "filebucket did not run successfully")
28
 
 
29
 
        assert_equal(file, outfile, "did not output correct file name")
30
 
        assert_equal(md5, outmd5, "did not output correct md5 sum")
31
 
 
32
 
        dipper = Puppet::Network::Client.dipper.new(:Path => bucket)
33
 
 
34
 
        newtext = nil
35
 
        assert_nothing_raised("Could not get file from bucket") do
36
 
            newtext = dipper.getfile(md5)
37
 
        end
38
 
 
39
 
        assert_equal(text, newtext, "did not get correct file from md5 sum")
40
 
 
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")
44
 
 
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")
49
 
    end
50
 
end
51