fs-snapshot 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/fs-snapshot.gemspec +1 -1
- data/lib/fs-snapshot/fs-snapshoter.rb +3 -0
- data/test/helper.rb +1 -0
- data/test/test_fs-snapshoter.rb +12 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/fs-snapshot.gemspec
CHANGED
@@ -21,6 +21,7 @@ class FsSnapshoter
|
|
21
21
|
|
22
22
|
# Takes a snapshot.
|
23
23
|
def take(name)
|
24
|
+
raise "Snapshot already exists - '#{name}'!" if list.include? name
|
24
25
|
dir = snapshot_dir(name)
|
25
26
|
dir.mkdir
|
26
27
|
FileUtils.cp_r @data_dir.to_str + '/.', dir
|
@@ -29,6 +30,7 @@ class FsSnapshoter
|
|
29
30
|
|
30
31
|
# Restores a snapshot.
|
31
32
|
def restore(name)
|
33
|
+
raise "No such snapshot - '#{name}'!" unless list.include? name
|
32
34
|
FileUtils.rm_rf @data_dir
|
33
35
|
FileUtils.cp_r snapshot_dir(name).to_str + '/.', @data_dir
|
34
36
|
return true
|
@@ -36,6 +38,7 @@ class FsSnapshoter
|
|
36
38
|
|
37
39
|
# Deletes a snapshot.
|
38
40
|
def delete(name)
|
41
|
+
raise "No such snapshot - '#{name}'!" unless list.include? name
|
39
42
|
FileUtils.rm_r snapshot_dir(name)
|
40
43
|
return true
|
41
44
|
end
|
data/test/helper.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'test/unit'
|
3
3
|
require 'shoulda'
|
4
4
|
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'fs-snapshot'))
|
5
6
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
7
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
8
|
require 'fs-snapshoter'
|
data/test/test_fs-snapshoter.rb
CHANGED
@@ -65,6 +65,18 @@ class TestFsSnapshoter < Test::Unit::TestCase
|
|
65
65
|
assert_equal ['snap1'], @snapshoter.list
|
66
66
|
assert_equal children, all_children(@data_dir)
|
67
67
|
end
|
68
|
+
|
69
|
+
should "raise exceptions" do
|
70
|
+
assert_raise RuntimeError do
|
71
|
+
@snapshoter.take('snap1')
|
72
|
+
end
|
73
|
+
assert_raise RuntimeError do
|
74
|
+
@snapshoter.restore('no_such_snapshot')
|
75
|
+
end
|
76
|
+
assert_raise RuntimeError do
|
77
|
+
@snapshoter.delete('no_such_snapshot')
|
78
|
+
end
|
79
|
+
end
|
68
80
|
end
|
69
81
|
|
70
82
|
end
|