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/base_spec.rb
CHANGED
|
@@ -5,33 +5,53 @@ require File.expand_path('../../spec_helper.rb', __FILE__)
|
|
|
5
5
|
describe Backup::Storage::Base do
|
|
6
6
|
let(:model) { Backup::Model.new(:test_trigger, 'test label') }
|
|
7
7
|
let(:package) { mock }
|
|
8
|
-
let(:
|
|
8
|
+
let(:storage) { Backup::Storage::Base.new(model) }
|
|
9
|
+
|
|
10
|
+
it 'should include Configuration::Helpers' do
|
|
11
|
+
Backup::Storage::Base.
|
|
12
|
+
include?(Backup::Configuration::Helpers).should be_true
|
|
13
|
+
end
|
|
9
14
|
|
|
10
15
|
describe '#initialize' do
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
after { Backup::Storage::Base.clear_defaults! }
|
|
17
|
+
|
|
18
|
+
it 'should load pre-configured defaults' do
|
|
19
|
+
Backup::Storage::Base.any_instance.expects(:load_defaults!)
|
|
20
|
+
storage
|
|
16
21
|
end
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
it 'should set a reference to the model' do
|
|
24
|
+
storage.instance_variable_get(:@model).should == model
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should set a reference to the storage_id' do
|
|
28
|
+
storage = Backup::Storage::Base.new(model, 'test_id')
|
|
29
|
+
storage.storage_id.should == 'test_id'
|
|
23
30
|
end
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
it 'should not require the storage_id' do
|
|
33
|
+
storage.instance_variable_defined?(:@storage_id).should be_true
|
|
34
|
+
storage.storage_id.should be_nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context 'when no pre-configured defaults have been set' do
|
|
38
|
+
it 'should set default values' do
|
|
39
|
+
storage.keep.should be_nil
|
|
40
|
+
storage.storage_id.should be_nil
|
|
41
|
+
end
|
|
42
|
+
end # context 'when no pre-configured defaults have been set'
|
|
43
|
+
|
|
44
|
+
context 'when pre-configured defaults have been set' do
|
|
45
|
+
before do
|
|
46
|
+
Backup::Storage::Base.defaults do |s|
|
|
47
|
+
s.keep = 5
|
|
30
48
|
end
|
|
31
|
-
base = Backup::Storage::Base.new(model)
|
|
32
|
-
base.keep.should be(5)
|
|
33
49
|
end
|
|
34
|
-
|
|
50
|
+
|
|
51
|
+
it 'should use pre-configured defaults' do
|
|
52
|
+
storage.keep.should be(5)
|
|
53
|
+
end
|
|
54
|
+
end # context 'when pre-configured defaults have been set'
|
|
35
55
|
end # describe '#initialize'
|
|
36
56
|
|
|
37
57
|
describe '#perform!' do
|
|
@@ -41,31 +61,31 @@ describe Backup::Storage::Base do
|
|
|
41
61
|
|
|
42
62
|
it 'should call #transfer!, then #cycle!' do
|
|
43
63
|
s = sequence ''
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
64
|
+
storage.expects(:transfer!).in_sequence(s)
|
|
65
|
+
storage.expects(:cycle!).in_sequence(s)
|
|
66
|
+
storage.perform!
|
|
67
|
+
storage.instance_variable_get(:@package).should be(package)
|
|
48
68
|
end
|
|
49
69
|
end
|
|
50
70
|
|
|
51
71
|
describe '#storage_name' do
|
|
52
72
|
context 'when given a storage_id' do
|
|
53
|
-
before {
|
|
73
|
+
before { storage.storage_id = 'storage id' }
|
|
54
74
|
it 'should return a log-friendly name with the storage_id' do
|
|
55
|
-
|
|
75
|
+
storage.send(:storage_name).should == 'Storage::Base (storage id)'
|
|
56
76
|
end
|
|
57
77
|
end
|
|
58
78
|
|
|
59
79
|
context 'when not given a storage_id' do
|
|
60
80
|
it 'should return a log-friendly name without a storage_id' do
|
|
61
|
-
|
|
81
|
+
storage.send(:storage_name).should == 'Storage::Base'
|
|
62
82
|
end
|
|
63
83
|
end
|
|
64
84
|
end
|
|
65
85
|
|
|
66
86
|
describe '#local_path' do
|
|
67
87
|
it 'should return the configured tmp_path' do
|
|
68
|
-
|
|
88
|
+
storage.send(:local_path).should == Backup::Config.tmp_path
|
|
69
89
|
end
|
|
70
90
|
end
|
|
71
91
|
|
|
@@ -73,11 +93,11 @@ describe Backup::Storage::Base do
|
|
|
73
93
|
before do
|
|
74
94
|
package.expects(:trigger).returns('test_trigger')
|
|
75
95
|
package.expects(:time).returns('backup_time')
|
|
76
|
-
|
|
96
|
+
storage.expects(:path).returns('base/remote/path')
|
|
77
97
|
end
|
|
78
98
|
|
|
79
99
|
it 'should return the remote_path for the given package' do
|
|
80
|
-
|
|
100
|
+
storage.send(:remote_path_for, package).should ==
|
|
81
101
|
File.join('base/remote/path', 'test_trigger', 'backup_time')
|
|
82
102
|
end
|
|
83
103
|
end
|
|
@@ -98,47 +118,47 @@ describe Backup::Storage::Base do
|
|
|
98
118
|
given_block.expects(:got).with(
|
|
99
119
|
'2011.12.31.11.00.02.backup.tar.enc-ab', 'backup.tar.enc-ab'
|
|
100
120
|
)
|
|
101
|
-
|
|
121
|
+
storage.send(:files_to_transfer_for, package) do |local_file, remote_file|
|
|
102
122
|
given_block.got(local_file, remote_file)
|
|
103
123
|
end
|
|
104
124
|
end
|
|
105
125
|
|
|
106
126
|
it 'should have an alias method called #transferred_files_for' do
|
|
107
|
-
|
|
108
|
-
|
|
127
|
+
storage.method(:transferred_files_for).should ==
|
|
128
|
+
storage.method(:files_to_transfer_for)
|
|
109
129
|
end
|
|
110
130
|
end
|
|
111
131
|
|
|
112
132
|
describe '#cycle!' do
|
|
113
133
|
before do
|
|
114
|
-
|
|
115
|
-
|
|
134
|
+
storage.stubs(:storage_name).returns('Storage Name')
|
|
135
|
+
storage.instance_variable_set(:@package, package)
|
|
116
136
|
end
|
|
117
137
|
|
|
118
138
|
context 'when keep is set and > 0' do
|
|
119
|
-
before {
|
|
139
|
+
before { storage.keep = 1 }
|
|
120
140
|
it 'should cycle' do
|
|
121
141
|
s = sequence ''
|
|
122
142
|
Backup::Logger.expects(:message).in_sequence(s).
|
|
123
143
|
with('Storage Name: Cycling Started...')
|
|
124
144
|
Backup::Storage::Cycler.expects(:cycle!).in_sequence(s).
|
|
125
|
-
with(
|
|
145
|
+
with(storage, package)
|
|
126
146
|
Backup::Logger.expects(:message).in_sequence(s).
|
|
127
147
|
with('Storage Name: Cycling Complete!')
|
|
128
148
|
|
|
129
|
-
|
|
149
|
+
storage.send(:cycle!)
|
|
130
150
|
end
|
|
131
151
|
end
|
|
132
152
|
|
|
133
153
|
context 'when keep is not set or == 0' do
|
|
134
154
|
it 'should return nil when not set' do
|
|
135
|
-
|
|
136
|
-
|
|
155
|
+
storage.keep = nil
|
|
156
|
+
storage.send(:cycle!).should be_nil
|
|
137
157
|
end
|
|
138
158
|
|
|
139
159
|
it 'should return nil when == 0' do
|
|
140
|
-
|
|
141
|
-
|
|
160
|
+
storage.keep = 0
|
|
161
|
+
storage.send(:cycle!).should be_nil
|
|
142
162
|
end
|
|
143
163
|
end
|
|
144
164
|
end
|
|
@@ -14,38 +14,72 @@ describe Backup::Storage::CloudFiles do
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
it 'should be a subclass of Storage::Base' do
|
|
18
|
+
Backup::Storage::CloudFiles.
|
|
19
|
+
superclass.should == Backup::Storage::Base
|
|
20
|
+
end
|
|
21
|
+
|
|
17
22
|
describe '#initialize' do
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
storage
|
|
23
|
-
storage.servicenet.should == false
|
|
24
|
-
storage.path.should == 'backups'
|
|
25
|
-
|
|
26
|
-
storage.storage_id.should be_nil
|
|
27
|
-
storage.keep.should == 5
|
|
23
|
+
after { Backup::Storage::CloudFiles.clear_defaults! }
|
|
24
|
+
|
|
25
|
+
it 'should load pre-configured defaults through Base' do
|
|
26
|
+
Backup::Storage::CloudFiles.any_instance.expects(:load_defaults!)
|
|
27
|
+
storage
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
it 'should
|
|
31
|
-
|
|
32
|
-
cf.storage_id.should == 'my storage_id'
|
|
30
|
+
it 'should pass the model reference to Base' do
|
|
31
|
+
storage.instance_variable_get(:@model).should == model
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
it 'should pass the storage_id to Base' do
|
|
35
|
+
storage = Backup::Storage::CloudFiles.new(model, 'my_storage_id')
|
|
36
|
+
storage.storage_id.should == 'my_storage_id'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'when no pre-configured defaults have been set' do
|
|
40
|
+
it 'should use the values given' do
|
|
41
|
+
storage.username.should == 'my_username'
|
|
42
|
+
storage.api_key.should == 'my_api_key'
|
|
43
|
+
storage.auth_url.should == 'lon.auth.api.rackspacecloud.com'
|
|
44
|
+
storage.container.should == 'my_container'
|
|
45
|
+
storage.servicenet.should == false
|
|
46
|
+
storage.path.should == 'backups'
|
|
47
|
+
|
|
48
|
+
storage.storage_id.should be_nil
|
|
49
|
+
storage.keep.should == 5
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'should use default values if none are given' do
|
|
53
|
+
storage = Backup::Storage::CloudFiles.new(model)
|
|
54
|
+
|
|
55
|
+
storage.username.should be_nil
|
|
56
|
+
storage.api_key.should be_nil
|
|
57
|
+
storage.auth_url.should be_nil
|
|
58
|
+
storage.container.should be_nil
|
|
59
|
+
storage.servicenet.should == false
|
|
60
|
+
storage.path.should == 'backups'
|
|
61
|
+
|
|
62
|
+
storage.storage_id.should be_nil
|
|
63
|
+
storage.keep.should be_nil
|
|
64
|
+
end
|
|
65
|
+
end # context 'when no pre-configured defaults have been set'
|
|
66
|
+
|
|
67
|
+
context 'when pre-configured defaults have been set' do
|
|
68
|
+
before do
|
|
69
|
+
Backup::Storage::CloudFiles.defaults do |s|
|
|
70
|
+
s.username = 'some_username'
|
|
71
|
+
s.api_key = 'some_api_key'
|
|
72
|
+
s.auth_url = 'some_auth_url'
|
|
73
|
+
s.container = 'some_container'
|
|
74
|
+
s.servicenet = true
|
|
75
|
+
s.path = 'some_path'
|
|
76
|
+
s.keep = 15
|
|
47
77
|
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'should use pre-configured defaults' do
|
|
48
81
|
storage = Backup::Storage::CloudFiles.new(model)
|
|
82
|
+
|
|
49
83
|
storage.username.should == 'some_username'
|
|
50
84
|
storage.api_key.should == 'some_api_key'
|
|
51
85
|
storage.auth_url.should == 'some_auth_url'
|
|
@@ -57,24 +91,15 @@ describe Backup::Storage::CloudFiles do
|
|
|
57
91
|
storage.keep.should == 15
|
|
58
92
|
end
|
|
59
93
|
|
|
60
|
-
it 'should override
|
|
61
|
-
Backup::
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
storage = Backup::Storage::CloudFiles.new(model) do |cf|
|
|
71
|
-
cf.username = 'new_username'
|
|
72
|
-
cf.api_key = 'new_api_key'
|
|
73
|
-
cf.auth_url = 'new_auth_url'
|
|
74
|
-
cf.container = 'new_container'
|
|
75
|
-
cf.servicenet = false
|
|
76
|
-
cf.path = 'new_path'
|
|
77
|
-
cf.keep = 10
|
|
94
|
+
it 'should override pre-configured defaults' do
|
|
95
|
+
storage = Backup::Storage::CloudFiles.new(model) do |s|
|
|
96
|
+
s.username = 'new_username'
|
|
97
|
+
s.api_key = 'new_api_key'
|
|
98
|
+
s.auth_url = 'new_auth_url'
|
|
99
|
+
s.container = 'new_container'
|
|
100
|
+
s.servicenet = false
|
|
101
|
+
s.path = 'new_path'
|
|
102
|
+
s.keep = 10
|
|
78
103
|
end
|
|
79
104
|
|
|
80
105
|
storage.username.should == 'new_username'
|
|
@@ -87,8 +112,7 @@ describe Backup::Storage::CloudFiles do
|
|
|
87
112
|
storage.storage_id.should be_nil
|
|
88
113
|
storage.keep.should == 10
|
|
89
114
|
end
|
|
90
|
-
end # context 'when
|
|
91
|
-
|
|
115
|
+
end # context 'when pre-configured defaults have been set'
|
|
92
116
|
end # describe '#initialize'
|
|
93
117
|
|
|
94
118
|
describe '#provider' do
|
|
@@ -12,34 +12,65 @@ describe Backup::Storage::Dropbox do
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
it 'should be a subclass of Storage::Base' do
|
|
16
|
+
Backup::Storage::Dropbox.
|
|
17
|
+
superclass.should == Backup::Storage::Base
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
describe '#initialize' do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
storage
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
after { Backup::Storage::Dropbox.clear_defaults! }
|
|
22
|
+
|
|
23
|
+
it 'should load pre-configured defaults through Base' do
|
|
24
|
+
Backup::Storage::Dropbox.any_instance.expects(:load_defaults!)
|
|
25
|
+
storage
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should pass the model reference to Base' do
|
|
29
|
+
storage.instance_variable_get(:@model).should == model
|
|
24
30
|
end
|
|
25
31
|
|
|
26
|
-
it 'should
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
it 'should pass the storage_id to Base' do
|
|
33
|
+
storage = Backup::Storage::Dropbox.new(model, 'my_storage_id')
|
|
34
|
+
storage.storage_id.should == 'my_storage_id'
|
|
29
35
|
end
|
|
30
36
|
|
|
31
|
-
context 'when
|
|
32
|
-
|
|
37
|
+
context 'when no pre-configured defaults have been set' do
|
|
38
|
+
it 'should use the values given' do
|
|
39
|
+
storage.api_key.should == 'my_api_key'
|
|
40
|
+
storage.api_secret.should == 'my_api_secret'
|
|
41
|
+
storage.access_type.should == :app_folder
|
|
42
|
+
storage.path.should == 'backups'
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
storage.storage_id.should be_nil
|
|
45
|
+
storage.keep.should == 5
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'should use default values if none are given' do
|
|
49
|
+
storage = Backup::Storage::Dropbox.new(model)
|
|
50
|
+
storage.api_key.should be_nil
|
|
51
|
+
storage.api_secret.should be_nil
|
|
52
|
+
storage.access_type.should == :app_folder
|
|
53
|
+
storage.path.should == 'backups'
|
|
54
|
+
|
|
55
|
+
storage.storage_id.should be_nil
|
|
56
|
+
storage.keep.should be_nil
|
|
57
|
+
end
|
|
58
|
+
end # context 'when no pre-configured defaults have been set'
|
|
59
|
+
|
|
60
|
+
context 'when pre-configured defaults have been set' do
|
|
61
|
+
before do
|
|
62
|
+
Backup::Storage::Dropbox.defaults do |s|
|
|
63
|
+
s.api_key = 'some_api_key'
|
|
64
|
+
s.api_secret = 'some_api_secret'
|
|
65
|
+
s.access_type = 'some_access_type'
|
|
66
|
+
s.path = 'some_path'
|
|
67
|
+
s.keep = 15
|
|
41
68
|
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should use pre-configured defaults' do
|
|
42
72
|
storage = Backup::Storage::Dropbox.new(model)
|
|
73
|
+
|
|
43
74
|
storage.api_key.should == 'some_api_key'
|
|
44
75
|
storage.api_secret.should == 'some_api_secret'
|
|
45
76
|
storage.access_type.should == 'some_access_type'
|
|
@@ -49,20 +80,13 @@ describe Backup::Storage::Dropbox do
|
|
|
49
80
|
storage.keep.should == 15
|
|
50
81
|
end
|
|
51
82
|
|
|
52
|
-
it 'should override
|
|
53
|
-
Backup::
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
storage = Backup::Storage::Dropbox.new(model) do |db|
|
|
61
|
-
db.api_key = 'new_api_key'
|
|
62
|
-
db.api_secret = 'new_api_secret'
|
|
63
|
-
db.access_type = 'new_access_type'
|
|
64
|
-
db.path = 'new_path'
|
|
65
|
-
db.keep = 10
|
|
83
|
+
it 'should override pre-configured defaults' do
|
|
84
|
+
storage = Backup::Storage::Dropbox.new(model) do |s|
|
|
85
|
+
s.api_key = 'new_api_key'
|
|
86
|
+
s.api_secret = 'new_api_secret'
|
|
87
|
+
s.access_type = 'new_access_type'
|
|
88
|
+
s.path = 'new_path'
|
|
89
|
+
s.keep = 10
|
|
66
90
|
end
|
|
67
91
|
|
|
68
92
|
storage.api_key.should == 'new_api_key'
|
|
@@ -73,8 +97,7 @@ describe Backup::Storage::Dropbox do
|
|
|
73
97
|
storage.storage_id.should be_nil
|
|
74
98
|
storage.keep.should == 10
|
|
75
99
|
end
|
|
76
|
-
end # context 'when
|
|
77
|
-
|
|
100
|
+
end # context 'when pre-configured defaults have been set'
|
|
78
101
|
end # describe '#initialize'
|
|
79
102
|
|
|
80
103
|
describe '#connection' do
|
|
@@ -367,4 +390,103 @@ describe Backup::Storage::Dropbox do
|
|
|
367
390
|
end
|
|
368
391
|
end
|
|
369
392
|
|
|
393
|
+
describe 'deprecations' do
|
|
394
|
+
after do
|
|
395
|
+
Backup::Storage::Dropbox.clear_defaults!
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
describe '#email' do
|
|
399
|
+
context 'when set directly' do
|
|
400
|
+
it 'should issue a deprecation warning' do
|
|
401
|
+
Backup::Logger.expects(:warn).with do |err|
|
|
402
|
+
err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
|
|
403
|
+
" Backup::Storage::Dropbox.email has been deprecated " +
|
|
404
|
+
"as of backup v.3.0.17"
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
Backup::Storage::Dropbox.new(model) do |storage|
|
|
408
|
+
storage.email = 'foo'
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
context 'when set as a default' do
|
|
414
|
+
it 'should issue a deprecation warning' do
|
|
415
|
+
Backup::Logger.expects(:warn).with do |err|
|
|
416
|
+
err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
|
|
417
|
+
" Backup::Storage::Dropbox.email has been deprecated " +
|
|
418
|
+
"as of backup v.3.0.17"
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
Backup::Storage::Dropbox.defaults do |storage|
|
|
422
|
+
storage.email = 'foo'
|
|
423
|
+
end
|
|
424
|
+
Backup::Storage::Dropbox.new(model)
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
describe '#password' do
|
|
430
|
+
context 'when set directly' do
|
|
431
|
+
it 'should issue a deprecation warning' do
|
|
432
|
+
Backup::Logger.expects(:warn).with do |err|
|
|
433
|
+
err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
|
|
434
|
+
" Backup::Storage::Dropbox.password has been deprecated " +
|
|
435
|
+
"as of backup v.3.0.17"
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
Backup::Storage::Dropbox.new(model) do |storage|
|
|
439
|
+
storage.password = 'foo'
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
context 'when set as a default' do
|
|
445
|
+
it 'should issue a deprecation warning' do
|
|
446
|
+
Backup::Logger.expects(:warn).with do |err|
|
|
447
|
+
err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
|
|
448
|
+
" Backup::Storage::Dropbox.password has been deprecated " +
|
|
449
|
+
"as of backup v.3.0.17"
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
Backup::Storage::Dropbox.defaults do |storage|
|
|
453
|
+
storage.password = 'foo'
|
|
454
|
+
end
|
|
455
|
+
Backup::Storage::Dropbox.new(model)
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
describe '#timeout' do
|
|
461
|
+
context 'when set directly' do
|
|
462
|
+
it 'should issue a deprecation warning' do
|
|
463
|
+
Backup::Logger.expects(:warn).with do |err|
|
|
464
|
+
err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
|
|
465
|
+
" Backup::Storage::Dropbox.timeout has been deprecated " +
|
|
466
|
+
"as of backup v.3.0.21"
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
Backup::Storage::Dropbox.new(model) do |storage|
|
|
470
|
+
storage.timeout = 'foo'
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
context 'when set as a default' do
|
|
476
|
+
it 'should issue a deprecation warning' do
|
|
477
|
+
Backup::Logger.expects(:warn).with do |err|
|
|
478
|
+
err.message.should == "ConfigurationError: [DEPRECATION WARNING]\n" +
|
|
479
|
+
" Backup::Storage::Dropbox.timeout has been deprecated " +
|
|
480
|
+
"as of backup v.3.0.21"
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
Backup::Storage::Dropbox.defaults do |storage|
|
|
484
|
+
storage.timeout = 'foo'
|
|
485
|
+
end
|
|
486
|
+
Backup::Storage::Dropbox.new(model)
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
end
|
|
491
|
+
|
|
370
492
|
end
|