summaryrefslogtreecommitdiff
path: root/test/tc_restore.rb
blob: 426c2b1e690550c1e9369ac68151da3ed5275899 (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
35
36
$: << File.dirname(__FILE__)+"/../lib"

require 'test/unit'
require 'byteback/restore'
require 'tmpdir'
require 'time'
require 'fileutils'

class RestoreTest < Test::Unit::TestCase

  def setup
    @byteback_root = Dir.mktmpdir
    @snapshot = Time.now.iso8601
    FileUtils.mkdir_p(File.join(@byteback_root, @snapshot))
  end

  def teardown
    FileUtils.remove_entry_secure @byteback_root
  end

  def test_find
    files = %w(/srv/foo.com/public/htdocs/index.html
               /srv/foo.com/public/htdocs/app.php)

    files.each do |f|
      FileUtils.mkdir_p(File.join(@byteback_root, @snapshot, File.dirname(f)))
      FileUtils.touch(File.join(@byteback_root, @snapshot, f))
      system("setfattr --name user.rsync.%stat -v \"41755 12,34 56:78\" #{File.join(@byteback_root, @snapshot, f)}")
    end

    r = Byteback::Restore.find(@byteback_root, "*", "/srv/foo.com/public/htdocs/*.html")
  
    r.list 
  end

end