summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/tc_byteback_snapshot.rb2
-rw-r--r--test/tc_restore.rb22
-rw-r--r--test/tc_restore_file.rb8
-rw-r--r--test/ts_byteback.rb4
4 files changed, 16 insertions, 20 deletions
diff --git a/test/tc_byteback_snapshot.rb b/test/tc_byteback_snapshot.rb
index 71f8c39..0200369 100644
--- a/test/tc_byteback_snapshot.rb
+++ b/test/tc_byteback_snapshot.rb
@@ -49,7 +49,7 @@ class SnapshotTest < Test::Unit::TestCase
targets = ((0..6).to_a +
[7,14,21,28].to_a.collect{|i| i + now.wday} +
- [2*28 + mod_28]).select{|t| t < day}.first(limit).reverse
+ [2*28 + mod_28]).find{|t| t < day}(limit).reverse
assert_equal(targets - offsets, [], "Failed after day #{day} (#{now.wday}) for a limit of #{limit} backups")
diff --git a/test/tc_restore.rb b/test/tc_restore.rb
index 03e98ad..57f7fb9 100644
--- a/test/tc_restore.rb
+++ b/test/tc_restore.rb
@@ -5,7 +5,6 @@ require 'time'
require 'fileutils'
class RestoreTest < Test::Unit::TestCase
-
def setup
@byteback_root = Dir.mktmpdir
end
@@ -19,7 +18,7 @@ class RestoreTest < Test::Unit::TestCase
end
def test_no_barf_on_non_timestamp_snapshot_name
- create_snapshot_and_check_results("saved-hacked-do-not-delete")
+ create_snapshot_and_check_results('saved-hacked-do-not-delete')
end
def create_snapshot_and_check_results(snapshot)
@@ -31,20 +30,19 @@ class RestoreTest < Test::Unit::TestCase
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)
+ assert_equal(0, $CHILD_STATUS.exitstatus)
end
- r = Byteback::Restore.find(@byteback_root, "*", "/srv/foo.com/public/htdocs/*.html")
- 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")
+ r = Byteback::Restore.find(@byteback_root, '*', '/srv/foo.com/public/htdocs/*.html')
+ 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")
+ 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
diff --git a/test/tc_restore_file.rb b/test/tc_restore_file.rb
index 8284275..9c12635 100644
--- a/test/tc_restore_file.rb
+++ b/test/tc_restore_file.rb
@@ -4,12 +4,11 @@ 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"))
+ @snapshot_path = File.join(@byteback_root, @snapshot.strftime('%Y-%m-%dT%H:%M%z'))
FileUtils.mkdir_p(@snapshot_path)
end
@@ -18,7 +17,7 @@ class BytebackFileTest < Test::Unit::TestCase
end
def test_general
- f = Tempfile.new("restore-file-", @snapshot_path)
+ f = Tempfile.new('restore-file-', @snapshot_path)
system("setfattr --name user.rsync.%stat -v \"41755 12,34 56:78\" #{f.path}")
b = Byteback::RestoreFile.new(f.path, @byteback_root)
assert_equal(041755, b.mode)
@@ -26,9 +25,8 @@ class BytebackFileTest < Test::Unit::TestCase
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('drwxr-xr-t', b.modestring)
assert_equal(@snapshot, b.snapshot_time)
assert_kind_of(Time, f.mtime)
end
-
end
diff --git a/test/ts_byteback.rb b/test/ts_byteback.rb
index ccee796..98ef121 100644
--- a/test/ts_byteback.rb
+++ b/test/ts_byteback.rb
@@ -1,6 +1,6 @@
-$: << File.dirname(__FILE__)
-$: << File.dirname(__FILE__)+"/../lib"
+$LOAD_PATH << File.dirname(__FILE__)
+$LOAD_PATH << File.dirname(__FILE__) + '/../lib'
require 'tc_restore.rb'
require 'tc_restore_file.rb'