summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2017-01-31 11:03:27 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2017-01-31 11:03:27 +0000
commit566c4c39e58e001015d263df124ea88d06ba5940 (patch)
treeb29957f0d21fa0adcafab48bcd9f90bc05da022a /test
parent53f78a01f2fb514d61fdb076f5b749e03ffddb74 (diff)
Make sure that we accept any old snapshot name when restoring.
Also expand the tests to check that the correct ownership etc is being returned.
Diffstat (limited to 'test')
-rw-r--r--test/tc_restore.rb30
1 files changed, 23 insertions, 7 deletions
diff --git a/test/tc_restore.rb b/test/tc_restore.rb
index 364c7f1..03e98ad 100644
--- a/test/tc_restore.rb
+++ b/test/tc_restore.rb
@@ -8,8 +8,6 @@ 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
@@ -17,18 +15,36 @@ class RestoreTest < Test::Unit::TestCase
end
def test_find
+ create_snapshot_and_check_results(Time.now.iso8601.to_s)
+ end
+
+ def test_no_barf_on_non_timestamp_snapshot_name
+ create_snapshot_and_check_results("saved-hacked-do-not-delete")
+ end
+
+ def create_snapshot_and_check_results(snapshot)
+ FileUtils.mkdir_p(File.join(@byteback_root, snapshot))
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)}")
+ 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)}")
+ assert_equal(0, $?.exitstatus)
end
r = Byteback::Restore.find(@byteback_root, "*", "/srv/foo.com/public/htdocs/*.html")
-
- r.list
+ assert(r.results.all?{|f| f.path =~ %r{/srv/foo.com/public/htdocs/.*.html}}, "Results returned did not match requested pattern")
+ assert(r.results.all?{|f| f.snapshot == snapshot}, "Results returned were not from the correct snapshot")
+
+ # Now check that we're getting the correct stuff from the rsync attr.
+ f = r.results.first
+ assert_equal(041755, f.mode, "Incorrect mode returned")
+ assert_equal(12, f.dev_major, "Incorrect dev_major returned")
+ assert_equal(34, f.dev_minor, "Incorrect dev_minor returned")
+ assert_equal(56, f.uid, "Incorrect UID returned")
+ assert_equal(78, f.gid, "Inocrrect GID returned")
end
end