backup 3.0.23 → 3.0.24
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/Gemfile.lock +42 -45
- data/Guardfile +7 -4
- data/README.md +10 -7
- data/backup.gemspec +2 -2
- data/lib/backup.rb +27 -97
- data/lib/backup/archive.rb +14 -6
- data/lib/backup/cli/helpers.rb +52 -49
- data/lib/backup/cli/utility.rb +9 -1
- data/lib/backup/compressor/base.rb +10 -4
- data/lib/backup/compressor/bzip2.rb +22 -26
- data/lib/backup/compressor/custom.rb +53 -0
- data/lib/backup/compressor/gzip.rb +22 -23
- data/lib/backup/compressor/lzma.rb +15 -13
- data/lib/backup/compressor/pbzip2.rb +20 -17
- data/lib/backup/config.rb +6 -3
- data/lib/backup/configuration.rb +33 -0
- data/lib/backup/configuration/helpers.rb +114 -28
- data/lib/backup/configuration/store.rb +24 -0
- data/lib/backup/database/base.rb +0 -6
- data/lib/backup/database/mongodb.rb +27 -11
- data/lib/backup/database/mysql.rb +19 -14
- data/lib/backup/database/postgresql.rb +16 -11
- data/lib/backup/database/redis.rb +7 -11
- data/lib/backup/database/riak.rb +3 -6
- data/lib/backup/dependency.rb +5 -11
- data/lib/backup/model.rb +14 -5
- data/lib/backup/notifier/campfire.rb +3 -16
- data/lib/backup/notifier/hipchat.rb +1 -7
- data/lib/backup/notifier/mail.rb +1 -1
- data/lib/backup/packager.rb +29 -19
- data/lib/backup/pipeline.rb +110 -0
- data/lib/backup/storage/dropbox.rb +4 -7
- data/lib/backup/syncer/base.rb +8 -4
- data/lib/backup/syncer/cloud/base.rb +247 -0
- data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
- data/lib/backup/syncer/cloud/s3.rb +68 -0
- data/lib/backup/syncer/rsync/base.rb +1 -4
- data/lib/backup/syncer/rsync/local.rb +9 -5
- data/lib/backup/syncer/rsync/pull.rb +1 -1
- data/lib/backup/syncer/rsync/push.rb +10 -5
- data/lib/backup/version.rb +1 -1
- data/spec-live/.gitignore +6 -0
- data/spec-live/README +7 -0
- data/spec-live/backups/config.rb +153 -0
- data/spec-live/backups/config.yml.template +43 -0
- data/spec-live/compressor/custom_spec.rb +30 -0
- data/spec-live/compressor/gzip_spec.rb +30 -0
- data/spec-live/notifier/mail_spec.rb +85 -0
- data/spec-live/spec_helper.rb +85 -0
- data/spec-live/storage/dropbox_spec.rb +151 -0
- data/spec-live/storage/local_spec.rb +83 -0
- data/spec-live/storage/scp_spec.rb +193 -0
- data/spec-live/syncer/cloud/s3_spec.rb +124 -0
- data/spec/archive_spec.rb +86 -31
- data/spec/cleaner_spec.rb +8 -0
- data/spec/cli/helpers_spec.rb +200 -75
- data/spec/cli/utility_spec.rb +11 -3
- data/spec/compressor/base_spec.rb +31 -10
- data/spec/compressor/bzip2_spec.rb +212 -57
- data/spec/compressor/custom_spec.rb +106 -0
- data/spec/compressor/gzip_spec.rb +212 -57
- data/spec/compressor/lzma_spec.rb +75 -35
- data/spec/compressor/pbzip2_spec.rb +93 -52
- data/spec/configuration/helpers_spec.rb +406 -0
- data/spec/configuration/store_spec.rb +39 -0
- data/spec/configuration_spec.rb +62 -0
- data/spec/database/base_spec.rb +19 -10
- data/spec/database/mongodb_spec.rb +195 -70
- data/spec/database/mysql_spec.rb +183 -64
- data/spec/database/postgresql_spec.rb +167 -53
- data/spec/database/redis_spec.rb +121 -46
- data/spec/database/riak_spec.rb +96 -27
- data/spec/dependency_spec.rb +2 -0
- data/spec/encryptor/base_spec.rb +10 -0
- data/spec/encryptor/gpg_spec.rb +29 -13
- data/spec/encryptor/open_ssl_spec.rb +40 -21
- data/spec/logger_spec.rb +4 -0
- data/spec/model_spec.rb +19 -2
- data/spec/notifier/base_spec.rb +32 -17
- data/spec/notifier/campfire_spec.rb +63 -45
- data/spec/notifier/hipchat_spec.rb +79 -56
- data/spec/notifier/mail_spec.rb +82 -46
- data/spec/notifier/prowl_spec.rb +53 -32
- data/spec/notifier/twitter_spec.rb +62 -41
- data/spec/packager_spec.rb +95 -36
- data/spec/pipeline_spec.rb +259 -0
- data/spec/spec_helper.rb +6 -5
- data/spec/storage/base_spec.rb +61 -41
- data/spec/storage/cloudfiles_spec.rb +69 -45
- data/spec/storage/dropbox_spec.rb +158 -36
- data/spec/storage/ftp_spec.rb +69 -45
- data/spec/storage/local_spec.rb +47 -23
- data/spec/storage/ninefold_spec.rb +55 -31
- data/spec/storage/rsync_spec.rb +67 -50
- data/spec/storage/s3_spec.rb +65 -41
- data/spec/storage/scp_spec.rb +65 -41
- data/spec/storage/sftp_spec.rb +65 -41
- data/spec/syncer/base_spec.rb +91 -4
- data/spec/syncer/cloud/base_spec.rb +511 -0
- data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
- data/spec/syncer/cloud/s3_spec.rb +174 -0
- data/spec/syncer/rsync/base_spec.rb +46 -66
- data/spec/syncer/rsync/local_spec.rb +55 -26
- data/spec/syncer/rsync/pull_spec.rb +15 -4
- data/spec/syncer/rsync/push_spec.rb +59 -52
- data/templates/cli/utility/compressor/bzip2 +1 -4
- data/templates/cli/utility/compressor/custom +11 -0
- data/templates/cli/utility/compressor/gzip +1 -4
- data/templates/cli/utility/compressor/lzma +3 -0
- data/templates/cli/utility/compressor/pbzip2 +3 -0
- data/templates/cli/utility/database/mysql +4 -1
- data/templates/cli/utility/syncer/cloud_files +17 -19
- data/templates/cli/utility/syncer/s3 +18 -20
- metadata +38 -92
- data/lib/backup/configuration/base.rb +0 -15
- data/lib/backup/configuration/compressor/base.rb +0 -9
- data/lib/backup/configuration/compressor/bzip2.rb +0 -23
- data/lib/backup/configuration/compressor/gzip.rb +0 -23
- data/lib/backup/configuration/compressor/lzma.rb +0 -23
- data/lib/backup/configuration/compressor/pbzip2.rb +0 -28
- data/lib/backup/configuration/database/base.rb +0 -19
- data/lib/backup/configuration/database/mongodb.rb +0 -49
- data/lib/backup/configuration/database/mysql.rb +0 -42
- data/lib/backup/configuration/database/postgresql.rb +0 -41
- data/lib/backup/configuration/database/redis.rb +0 -39
- data/lib/backup/configuration/database/riak.rb +0 -29
- data/lib/backup/configuration/encryptor/base.rb +0 -9
- data/lib/backup/configuration/encryptor/gpg.rb +0 -17
- data/lib/backup/configuration/encryptor/open_ssl.rb +0 -32
- data/lib/backup/configuration/notifier/base.rb +0 -28
- data/lib/backup/configuration/notifier/campfire.rb +0 -25
- data/lib/backup/configuration/notifier/hipchat.rb +0 -41
- data/lib/backup/configuration/notifier/mail.rb +0 -112
- data/lib/backup/configuration/notifier/presently.rb +0 -25
- data/lib/backup/configuration/notifier/prowl.rb +0 -23
- data/lib/backup/configuration/notifier/twitter.rb +0 -21
- data/lib/backup/configuration/storage/base.rb +0 -18
- data/lib/backup/configuration/storage/cloudfiles.rb +0 -25
- data/lib/backup/configuration/storage/dropbox.rb +0 -58
- data/lib/backup/configuration/storage/ftp.rb +0 -29
- data/lib/backup/configuration/storage/local.rb +0 -17
- data/lib/backup/configuration/storage/ninefold.rb +0 -20
- data/lib/backup/configuration/storage/rsync.rb +0 -29
- data/lib/backup/configuration/storage/s3.rb +0 -25
- data/lib/backup/configuration/storage/scp.rb +0 -25
- data/lib/backup/configuration/storage/sftp.rb +0 -25
- data/lib/backup/configuration/syncer/base.rb +0 -10
- data/lib/backup/configuration/syncer/cloud.rb +0 -23
- data/lib/backup/configuration/syncer/cloud_files.rb +0 -30
- data/lib/backup/configuration/syncer/rsync/base.rb +0 -28
- data/lib/backup/configuration/syncer/rsync/local.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/pull.rb +0 -11
- data/lib/backup/configuration/syncer/rsync/push.rb +0 -31
- data/lib/backup/configuration/syncer/s3.rb +0 -23
- data/lib/backup/notifier/presently.rb +0 -88
- data/lib/backup/syncer/cloud.rb +0 -187
- data/lib/backup/syncer/cloud_files.rb +0 -56
- data/lib/backup/syncer/s3.rb +0 -47
- data/spec/configuration/base_spec.rb +0 -35
- data/spec/configuration/compressor/bzip2_spec.rb +0 -29
- data/spec/configuration/compressor/gzip_spec.rb +0 -29
- data/spec/configuration/compressor/lzma_spec.rb +0 -29
- data/spec/configuration/compressor/pbzip2_spec.rb +0 -32
- data/spec/configuration/database/base_spec.rb +0 -17
- data/spec/configuration/database/mongodb_spec.rb +0 -56
- data/spec/configuration/database/mysql_spec.rb +0 -53
- data/spec/configuration/database/postgresql_spec.rb +0 -53
- data/spec/configuration/database/redis_spec.rb +0 -50
- data/spec/configuration/database/riak_spec.rb +0 -35
- data/spec/configuration/encryptor/gpg_spec.rb +0 -26
- data/spec/configuration/encryptor/open_ssl_spec.rb +0 -35
- data/spec/configuration/notifier/base_spec.rb +0 -32
- data/spec/configuration/notifier/campfire_spec.rb +0 -32
- data/spec/configuration/notifier/hipchat_spec.rb +0 -44
- data/spec/configuration/notifier/mail_spec.rb +0 -71
- data/spec/configuration/notifier/presently_spec.rb +0 -35
- data/spec/configuration/notifier/prowl_spec.rb +0 -29
- data/spec/configuration/notifier/twitter_spec.rb +0 -35
- data/spec/configuration/storage/cloudfiles_spec.rb +0 -41
- data/spec/configuration/storage/dropbox_spec.rb +0 -38
- data/spec/configuration/storage/ftp_spec.rb +0 -44
- data/spec/configuration/storage/local_spec.rb +0 -29
- data/spec/configuration/storage/ninefold_spec.rb +0 -32
- data/spec/configuration/storage/rsync_spec.rb +0 -41
- data/spec/configuration/storage/s3_spec.rb +0 -38
- data/spec/configuration/storage/scp_spec.rb +0 -41
- data/spec/configuration/storage/sftp_spec.rb +0 -41
- data/spec/configuration/syncer/cloud_files_spec.rb +0 -44
- data/spec/configuration/syncer/rsync/base_spec.rb +0 -33
- data/spec/configuration/syncer/rsync/local_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/pull_spec.rb +0 -10
- data/spec/configuration/syncer/rsync/push_spec.rb +0 -43
- data/spec/configuration/syncer/s3_spec.rb +0 -38
- data/spec/notifier/presently_spec.rb +0 -181
- data/spec/syncer/cloud_files_spec.rb +0 -192
- data/spec/syncer/s3_spec.rb +0 -192
- data/templates/cli/utility/notifier/presently +0 -13
data/spec/storage/ftp_spec.rb
CHANGED
|
@@ -13,22 +13,26 @@ describe Backup::Storage::FTP do
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
it 'should be a subclass of Storage::Base' do
|
|
17
|
+
Backup::Storage::FTP.
|
|
18
|
+
superclass.should == Backup::Storage::Base
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
describe '#initialize' do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
storage
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
storage.
|
|
26
|
-
storage.keep.should == 5
|
|
22
|
+
after { Backup::Storage::FTP.clear_defaults! }
|
|
23
|
+
|
|
24
|
+
it 'should load pre-configured defaults through Base' do
|
|
25
|
+
Backup::Storage::FTP.any_instance.expects(:load_defaults!)
|
|
26
|
+
storage
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should pass the model reference to Base' do
|
|
30
|
+
storage.instance_variable_get(:@model).should == model
|
|
27
31
|
end
|
|
28
32
|
|
|
29
|
-
it 'should
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
it 'should pass the storage_id to Base' do
|
|
34
|
+
storage = Backup::Storage::FTP.new(model, 'my_storage_id')
|
|
35
|
+
storage.storage_id.should == 'my_storage_id'
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
it 'should remove any preceeding tilde and slash from the path' do
|
|
@@ -38,20 +42,50 @@ describe Backup::Storage::FTP do
|
|
|
38
42
|
storage.path.should == 'my_backups/path'
|
|
39
43
|
end
|
|
40
44
|
|
|
41
|
-
context 'when
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
context 'when no pre-configured defaults have been set' do
|
|
46
|
+
it 'should use the values given' do
|
|
47
|
+
storage.username.should == 'my_username'
|
|
48
|
+
storage.password.should == 'my_password'
|
|
49
|
+
storage.ip.should == '123.45.678.90'
|
|
50
|
+
storage.port.should == 21
|
|
51
|
+
storage.path.should == 'backups'
|
|
52
|
+
storage.passive_mode.should == false
|
|
53
|
+
|
|
54
|
+
storage.storage_id.should be_nil
|
|
55
|
+
storage.keep.should == 5
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'should use default values if none are given' do
|
|
59
|
+
storage = Backup::Storage::FTP.new(model)
|
|
60
|
+
|
|
61
|
+
storage.username.should be_nil
|
|
62
|
+
storage.password.should be_nil
|
|
63
|
+
storage.ip.should be_nil
|
|
64
|
+
storage.port.should == 21
|
|
65
|
+
storage.path.should == 'backups'
|
|
66
|
+
storage.passive_mode.should == false
|
|
67
|
+
|
|
68
|
+
storage.storage_id.should be_nil
|
|
69
|
+
storage.keep.should be_nil
|
|
70
|
+
end
|
|
71
|
+
end # context 'when no pre-configured defaults have been set'
|
|
72
|
+
|
|
73
|
+
context 'when pre-configured defaults have been set' do
|
|
74
|
+
before do
|
|
75
|
+
Backup::Storage::FTP.defaults do |s|
|
|
76
|
+
s.username = 'some_username'
|
|
77
|
+
s.password = 'some_password'
|
|
78
|
+
s.ip = 'some_ip'
|
|
79
|
+
s.port = 'some_port'
|
|
80
|
+
s.path = 'some_path'
|
|
81
|
+
s.passive_mode = 'some_passive_mode'
|
|
82
|
+
s.keep = 'some_keep'
|
|
53
83
|
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'should use pre-configured defaults' do
|
|
54
87
|
storage = Backup::Storage::FTP.new(model)
|
|
88
|
+
|
|
55
89
|
storage.username.should == 'some_username'
|
|
56
90
|
storage.password.should == 'some_password'
|
|
57
91
|
storage.ip.should == 'some_ip'
|
|
@@ -63,24 +97,15 @@ describe Backup::Storage::FTP do
|
|
|
63
97
|
storage.keep.should == 'some_keep'
|
|
64
98
|
end
|
|
65
99
|
|
|
66
|
-
it 'should override
|
|
67
|
-
Backup::
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
storage = Backup::Storage::FTP.new(model) do |ftp|
|
|
77
|
-
ftp.username = 'new_username'
|
|
78
|
-
ftp.password = 'new_password'
|
|
79
|
-
ftp.ip = 'new_ip'
|
|
80
|
-
ftp.port = 'new_port'
|
|
81
|
-
ftp.path = 'new_path'
|
|
82
|
-
ftp.passive_mode = 'new_passive_mode'
|
|
83
|
-
ftp.keep = 'new_keep'
|
|
100
|
+
it 'should override pre-configured defaults' do
|
|
101
|
+
storage = Backup::Storage::FTP.new(model) do |s|
|
|
102
|
+
s.username = 'new_username'
|
|
103
|
+
s.password = 'new_password'
|
|
104
|
+
s.ip = 'new_ip'
|
|
105
|
+
s.port = 'new_port'
|
|
106
|
+
s.path = 'new_path'
|
|
107
|
+
s.passive_mode = 'new_passive_mode'
|
|
108
|
+
s.keep = 'new_keep'
|
|
84
109
|
end
|
|
85
110
|
|
|
86
111
|
storage.username.should == 'new_username'
|
|
@@ -93,8 +118,7 @@ describe Backup::Storage::FTP do
|
|
|
93
118
|
storage.storage_id.should be_nil
|
|
94
119
|
storage.keep.should == 'new_keep'
|
|
95
120
|
end
|
|
96
|
-
end # context 'when
|
|
97
|
-
|
|
121
|
+
end # context 'when pre-configured defaults have been set'
|
|
98
122
|
end # describe '#initialize'
|
|
99
123
|
|
|
100
124
|
describe '#connection' do
|
data/spec/storage/local_spec.rb
CHANGED
|
@@ -13,17 +13,26 @@ describe Backup::Storage::Local do
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
it 'should be a subclass of Storage::Base' do
|
|
17
|
+
Backup::Storage::Local.
|
|
18
|
+
superclass.should == Backup::Storage::Base
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
describe '#initialize' do
|
|
17
|
-
|
|
18
|
-
storage.path.should == storage_path
|
|
22
|
+
after { Backup::Storage::Local.clear_defaults! }
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
it 'should load pre-configured defaults through Base' do
|
|
25
|
+
Backup::Storage::Local.any_instance.expects(:load_defaults!)
|
|
26
|
+
storage
|
|
22
27
|
end
|
|
23
28
|
|
|
24
|
-
it 'should
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
it 'should pass the model reference to Base' do
|
|
30
|
+
storage.instance_variable_get(:@model).should == model
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should pass the storage_id to Base' do
|
|
34
|
+
storage = Backup::Storage::Local.new(model, 'my_storage_id')
|
|
35
|
+
storage.storage_id.should == 'my_storage_id'
|
|
27
36
|
end
|
|
28
37
|
|
|
29
38
|
it 'should expand any path given' do
|
|
@@ -33,29 +42,45 @@ describe Backup::Storage::Local do
|
|
|
33
42
|
storage.path.should == File.expand_path('my_backups/path')
|
|
34
43
|
end
|
|
35
44
|
|
|
36
|
-
context 'when
|
|
37
|
-
|
|
45
|
+
context 'when no pre-configured defaults have been set' do
|
|
46
|
+
it 'should use the values given' do
|
|
47
|
+
storage.path.should == storage_path
|
|
48
|
+
|
|
49
|
+
storage.storage_id.should be_nil
|
|
50
|
+
storage.keep.should == 5
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'should use default values if none are given' do
|
|
54
|
+
storage = Backup::Storage::Local.new(model)
|
|
55
|
+
|
|
56
|
+
storage.path.should == storage_path
|
|
38
57
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
storage.storage_id.should be_nil
|
|
59
|
+
storage.keep.should be_nil
|
|
60
|
+
end
|
|
61
|
+
end # context 'when no pre-configured defaults have been set'
|
|
62
|
+
|
|
63
|
+
context 'when pre-configured defaults have been set' do
|
|
64
|
+
before do
|
|
65
|
+
Backup::Storage::Local.defaults do |s|
|
|
66
|
+
s.path = 'some_path'
|
|
67
|
+
s.keep = 'some_keep'
|
|
43
68
|
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should use pre-configured defaults' do
|
|
44
72
|
storage = Backup::Storage::Local.new(model)
|
|
73
|
+
|
|
45
74
|
storage.path.should == File.expand_path('some_path')
|
|
46
75
|
|
|
47
76
|
storage.storage_id.should be_nil
|
|
48
77
|
storage.keep.should == 'some_keep'
|
|
49
78
|
end
|
|
50
79
|
|
|
51
|
-
it 'should override
|
|
52
|
-
Backup::
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
storage = Backup::Storage::Local.new(model) do |local|
|
|
57
|
-
local.path = 'new_path'
|
|
58
|
-
local.keep = 'new_keep'
|
|
80
|
+
it 'should override pre-configured defaults' do
|
|
81
|
+
storage = Backup::Storage::Local.new(model) do |s|
|
|
82
|
+
s.path = 'new_path'
|
|
83
|
+
s.keep = 'new_keep'
|
|
59
84
|
end
|
|
60
85
|
|
|
61
86
|
storage.path.should == File.expand_path('new_path')
|
|
@@ -63,8 +88,7 @@ describe Backup::Storage::Local do
|
|
|
63
88
|
storage.storage_id.should be_nil
|
|
64
89
|
storage.keep.should == 'new_keep'
|
|
65
90
|
end
|
|
66
|
-
end # context 'when
|
|
67
|
-
|
|
91
|
+
end # context 'when pre-configured defaults have been set'
|
|
68
92
|
end # describe '#initialize'
|
|
69
93
|
|
|
70
94
|
describe '#transfer!' do
|
|
@@ -12,32 +12,63 @@ describe Backup::Storage::Ninefold do
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
it 'should be a subclass of Storage::Base' do
|
|
16
|
+
Backup::Storage::Ninefold.
|
|
17
|
+
superclass.should == Backup::Storage::Base
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
describe '#initialize' do
|
|
16
|
-
|
|
17
|
-
storage.storage_token.should == 'my_token'
|
|
18
|
-
storage.storage_secret.should == 'my_secret'
|
|
19
|
-
storage.path.should == 'backups'
|
|
21
|
+
after { Backup::Storage::Ninefold.clear_defaults! }
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
it 'should load pre-configured defaults through Base' do
|
|
24
|
+
Backup::Storage::Ninefold.any_instance.expects(:load_defaults!)
|
|
25
|
+
storage
|
|
23
26
|
end
|
|
24
27
|
|
|
25
|
-
it 'should
|
|
26
|
-
|
|
27
|
-
nf.storage_id.should == 'my storage_id'
|
|
28
|
+
it 'should pass the model reference to Base' do
|
|
29
|
+
storage.instance_variable_get(:@model).should == model
|
|
28
30
|
end
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
it 'should pass the storage_id to Base' do
|
|
33
|
+
storage = Backup::Storage::Ninefold.new(model, 'my_storage_id')
|
|
34
|
+
storage.storage_id.should == 'my_storage_id'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context 'when no pre-configured defaults have been set' do
|
|
38
|
+
it 'should use the values given' do
|
|
39
|
+
storage.storage_token.should == 'my_token'
|
|
40
|
+
storage.storage_secret.should == 'my_secret'
|
|
41
|
+
storage.path.should == 'backups'
|
|
42
|
+
|
|
43
|
+
storage.storage_id.should be_nil
|
|
44
|
+
storage.keep.should == 5
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should use default values if none are given' do
|
|
48
|
+
storage = Backup::Storage::Ninefold.new(model)
|
|
49
|
+
|
|
50
|
+
storage.storage_token.should be_nil
|
|
51
|
+
storage.storage_secret.should be_nil
|
|
52
|
+
storage.path.should == 'backups'
|
|
32
53
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
storage.storage_id.should be_nil
|
|
55
|
+
storage.keep.should be_nil
|
|
56
|
+
end
|
|
57
|
+
end # context 'when no pre-configured defaults have been set'
|
|
58
|
+
|
|
59
|
+
context 'when pre-configured defaults have been set' do
|
|
60
|
+
before do
|
|
61
|
+
Backup::Storage::Ninefold.defaults do |s|
|
|
62
|
+
s.storage_token = 'some_token'
|
|
63
|
+
s.storage_secret = 'some_secret'
|
|
64
|
+
s.path = 'some_path'
|
|
65
|
+
s.keep = 15
|
|
39
66
|
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'should use pre-configured defaults' do
|
|
40
70
|
storage = Backup::Storage::Ninefold.new(model)
|
|
71
|
+
|
|
41
72
|
storage.storage_token.should == 'some_token'
|
|
42
73
|
storage.storage_secret.should == 'some_secret'
|
|
43
74
|
storage.path.should == 'some_path'
|
|
@@ -46,18 +77,12 @@ describe Backup::Storage::Ninefold do
|
|
|
46
77
|
storage.keep.should == 15
|
|
47
78
|
end
|
|
48
79
|
|
|
49
|
-
it 'should override
|
|
50
|
-
Backup::
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
storage = Backup::Storage::Ninefold.new(model) do |nf|
|
|
57
|
-
nf.storage_token = 'new_token'
|
|
58
|
-
nf.storage_secret = 'new_secret'
|
|
59
|
-
nf.path = 'new_path'
|
|
60
|
-
nf.keep = 10
|
|
80
|
+
it 'should override pre-configured defaults' do
|
|
81
|
+
storage = Backup::Storage::Ninefold.new(model) do |s|
|
|
82
|
+
s.storage_token = 'new_token'
|
|
83
|
+
s.storage_secret = 'new_secret'
|
|
84
|
+
s.path = 'new_path'
|
|
85
|
+
s.keep = 10
|
|
61
86
|
end
|
|
62
87
|
|
|
63
88
|
storage.storage_token.should == 'new_token'
|
|
@@ -67,8 +92,7 @@ describe Backup::Storage::Ninefold do
|
|
|
67
92
|
storage.storage_id.should be_nil
|
|
68
93
|
storage.keep.should == 10
|
|
69
94
|
end
|
|
70
|
-
end # context 'when
|
|
71
|
-
|
|
95
|
+
end # context 'when pre-configured defaults have been set'
|
|
72
96
|
end # describe '#initialize'
|
|
73
97
|
|
|
74
98
|
describe '#provider' do
|
data/spec/storage/rsync_spec.rb
CHANGED
|
@@ -13,45 +13,72 @@ describe Backup::Storage::RSync do
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
it 'should be a subclass of Storage::Base' do
|
|
17
|
+
Backup::Storage::RSync.
|
|
18
|
+
superclass.should == Backup::Storage::Base
|
|
19
|
+
end
|
|
20
|
+
|
|
16
21
|
describe '#initialize' do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
storage
|
|
22
|
-
storage.path.should == 'backups'
|
|
23
|
-
storage.local.should == false
|
|
24
|
-
|
|
25
|
-
storage.storage_id.should be_nil
|
|
26
|
-
storage.keep.should == 5
|
|
22
|
+
after { Backup::Storage::RSync.clear_defaults! }
|
|
23
|
+
|
|
24
|
+
it 'should load pre-configured defaults through Base' do
|
|
25
|
+
Backup::Storage::RSync.any_instance.expects(:load_defaults!)
|
|
26
|
+
storage
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
it 'should
|
|
30
|
-
|
|
31
|
-
rsync.storage_id.should == 'my storage_id'
|
|
29
|
+
it 'should pass the model reference to Base' do
|
|
30
|
+
storage.instance_variable_get(:@model).should == model
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
it 'should
|
|
35
|
-
storage = Backup::Storage::RSync.new(model)
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
storage.path.should == 'my_backups/path'
|
|
33
|
+
it 'should pass the storage_id to Base' do
|
|
34
|
+
storage = Backup::Storage::RSync.new(model, 'my_storage_id')
|
|
35
|
+
storage.storage_id.should == 'my_storage_id'
|
|
39
36
|
end
|
|
40
37
|
|
|
41
|
-
context 'when
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
context 'when no pre-configured defaults have been set' do
|
|
39
|
+
it 'should use the values given' do
|
|
40
|
+
storage.username.should == 'my_username'
|
|
41
|
+
storage.password.should == 'my_password'
|
|
42
|
+
storage.ip.should == '123.45.678.90'
|
|
43
|
+
storage.port.should == 22
|
|
44
|
+
storage.path.should == 'backups'
|
|
45
|
+
storage.local.should == false
|
|
46
|
+
|
|
47
|
+
storage.storage_id.should be_nil
|
|
48
|
+
storage.keep.should == 5
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'should use default values if none are given' do
|
|
52
|
+
storage = Backup::Storage::RSync.new(model)
|
|
53
|
+
|
|
54
|
+
storage.username.should be_nil
|
|
55
|
+
storage.password.should be_nil
|
|
56
|
+
storage.ip.should be_nil
|
|
57
|
+
storage.port.should == 22
|
|
58
|
+
storage.path.should == 'backups'
|
|
59
|
+
storage.local.should == false
|
|
60
|
+
|
|
61
|
+
storage.storage_id.should be_nil
|
|
62
|
+
storage.keep.should be_nil
|
|
63
|
+
end
|
|
64
|
+
end # context 'when no pre-configured defaults have been set'
|
|
65
|
+
|
|
66
|
+
context 'when pre-configured defaults have been set' do
|
|
67
|
+
before do
|
|
68
|
+
Backup::Storage::RSync.defaults do |s|
|
|
69
|
+
s.username = 'some_username'
|
|
70
|
+
s.password = 'some_password'
|
|
71
|
+
s.ip = 'some_ip'
|
|
72
|
+
s.port = 'some_port'
|
|
73
|
+
s.path = 'some_path'
|
|
74
|
+
s.local = 'some_local'
|
|
75
|
+
s.keep = 'some_keep'
|
|
53
76
|
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'should use pre-configured defaults' do
|
|
54
80
|
storage = Backup::Storage::RSync.new(model)
|
|
81
|
+
|
|
55
82
|
storage.username.should == 'some_username'
|
|
56
83
|
storage.password.should == 'some_password'
|
|
57
84
|
storage.ip.should == 'some_ip'
|
|
@@ -63,24 +90,15 @@ describe Backup::Storage::RSync do
|
|
|
63
90
|
storage.keep.should == 'some_keep'
|
|
64
91
|
end
|
|
65
92
|
|
|
66
|
-
it 'should override
|
|
67
|
-
Backup::
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
storage = Backup::Storage::RSync.new(model) do |rsync|
|
|
77
|
-
rsync.username = 'new_username'
|
|
78
|
-
rsync.password = 'new_password'
|
|
79
|
-
rsync.ip = 'new_ip'
|
|
80
|
-
rsync.port = 'new_port'
|
|
81
|
-
rsync.path = 'new_path'
|
|
82
|
-
rsync.local = 'new_local'
|
|
83
|
-
rsync.keep = 'new_keep'
|
|
93
|
+
it 'should override pre-configured defaults' do
|
|
94
|
+
storage = Backup::Storage::RSync.new(model) do |s|
|
|
95
|
+
s.username = 'new_username'
|
|
96
|
+
s.password = 'new_password'
|
|
97
|
+
s.ip = 'new_ip'
|
|
98
|
+
s.port = 'new_port'
|
|
99
|
+
s.path = 'new_path'
|
|
100
|
+
s.local = 'new_local'
|
|
101
|
+
s.keep = 'new_keep'
|
|
84
102
|
end
|
|
85
103
|
|
|
86
104
|
storage.username.should == 'new_username'
|
|
@@ -93,8 +111,7 @@ describe Backup::Storage::RSync do
|
|
|
93
111
|
storage.storage_id.should be_nil
|
|
94
112
|
storage.keep.should == 'new_keep'
|
|
95
113
|
end
|
|
96
|
-
end # context 'when
|
|
97
|
-
|
|
114
|
+
end # context 'when pre-configured defaults have been set'
|
|
98
115
|
end # describe '#initialize'
|
|
99
116
|
|
|
100
117
|
describe '#remote_path_for' do
|