summaryrefslogtreecommitdiffstats
path: root/test/network/client/dipper.rb
blob: 51494be9dc8598a93faa749d7a3b820153d96c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../lib/puppettest'

require 'puppettest'
require 'puppet/network/client/resource'

class TestDipperClient < Test::Unit::TestCase
    include PuppetTest::ServerTest

    def setup
        super
        @dipper = Puppet::Network::Client.dipper.new(:Path => tempfile)
    end

    # Make sure we can create a new file with 'restore'.
    def test_restore_to_new_file
        file = tempfile
        text = "asdf;lkajseofiqwekj"
        File.open(file, "w") { |f| f.puts text }
        md5 = nil
        assert_nothing_raised("Could not send file") do
            md5 = @dipper.backup(file)
        end

        newfile = tempfile
        assert_nothing_raised("could not restore to new path") do
            @dipper.restore(newfile, md5)
        end

        assert_equal(File.read(file), File.read(newfile), "did not restore correctly")
    end
end