fs-snapshot 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/fs-snapshot.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fs-snapshot}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aleksey Palazhchenko"]
@@ -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'
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fs-snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey Palazhchenko