diff options
author | Chris Elsworth <chris.elsworth@bytemark.co.uk> | 2017-01-31 11:17:20 +0000 |
---|---|---|
committer | Chris Elsworth <chris.elsworth@bytemark.co.uk> | 2017-01-31 11:17:20 +0000 |
commit | 1943b5a11ed6615816bd476d16f2f319edfc772d (patch) | |
tree | b29957f0d21fa0adcafab48bcd9f90bc05da022a /test/tc_restore.rb | |
parent | 1586557ca5639d160300697cd65067536b66e5d1 (diff) | |
parent | 566c4c39e58e001015d263df124ea88d06ba5940 (diff) |
Merge branch '7-error-when-non-timestamp-directory-in-backup-destination' into 'master'
Resolve "Error when non-timestamp directory in backup destination"
Closes #7
See merge request !6
Diffstat (limited to 'test/tc_restore.rb')
-rw-r--r-- | test/tc_restore.rb | 30 |
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 |