summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2015-12-02 09:53:42 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2015-12-02 09:53:42 +0000
commit2646474b9d25ca1368a39e93870e4f55b59a9ec7 (patch)
treeb3976104b907e7189c47703329bfd6dfa9c460af /test
parentae22f27388aa110c5a61e178f80988cf73154eff (diff)
Fixed up tests to work.
I'd changed some of the arguments to the functions, and not updated the tests. So much for TDD..!
Diffstat (limited to 'test')
-rw-r--r--test/tc_restore.rb2
-rw-r--r--test/tc_restore_file.rb23
2 files changed, 20 insertions, 5 deletions
diff --git a/test/tc_restore.rb b/test/tc_restore.rb
index f1e8b04..426c2b1 100644
--- a/test/tc_restore.rb
+++ b/test/tc_restore.rb
@@ -28,7 +28,7 @@ class RestoreTest < Test::Unit::TestCase
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 = Byteback::Restore.find(@byteback_root, "*", "/srv/foo.com/public/htdocs/*.html")
r.list
end
diff --git a/test/tc_restore_file.rb b/test/tc_restore_file.rb
index b0497b3..e9544f9 100644
--- a/test/tc_restore_file.rb
+++ b/test/tc_restore_file.rb
@@ -3,19 +3,34 @@ $: << File.dirname(__FILE__)+"/../lib"
require 'test/unit'
require 'byteback/restore_file'
require 'tempfile'
+require 'tmpdir'
class BytebackFileTest < Test::Unit::TestCase
+ def setup
+ @byteback_root = Dir.mktmpdir
+ now = Time.now
+ @snapshot = Time.local(now.year, now.month, now.day, now.hour, now.min)
+ @snapshot_path = File.join(@byteback_root, @snapshot.strftime("%Y-%m-%dT%H:%M%z"))
+ FileUtils.mkdir_p(@snapshot_path)
+ end
+
+ def teardown
+ FileUtils.remove_entry_secure @byteback_root
+ end
+
def test_general
- f = Tempfile.new($0)
+ f = Tempfile.new($0, @snapshot_path)
+ puts f.path
system("setfattr --name user.rsync.%stat -v \"41755 12,34 56:78\" #{f.path}")
- b = Byteback::RestoreFile.new(f.path)
+ b = Byteback::RestoreFile.new(f.path, @byteback_root)
assert_equal(041755, b.mode)
- assert_equal(12, b.maj)
- assert_equal(34, b.min)
+ assert_equal(12, b.dev_major)
+ assert_equal(34, b.dev_minor)
assert_equal(56, b.uid)
assert_equal(78, b.gid)
assert_equal("drwxr-xr-t", b.modestring)
+ assert_equal(@snapshot, b.snapshot_time)
assert_kind_of(Time, f.mtime)
end