backup 3.0.23 → 3.0.24
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -3,81 +3,236 @@
|
|
3
3
|
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
4
|
|
5
5
|
describe Backup::Compressor::Gzip do
|
6
|
-
|
6
|
+
before do
|
7
|
+
Backup::Compressor::Gzip.any_instance.stubs(:utility).returns('gzip')
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
it 'should be a subclass of Compressor::Base' do
|
11
|
+
Backup::Compressor::Gzip.
|
12
|
+
superclass.should == Backup::Compressor::Base
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
Backup::Configuration::Compressor::Gzip.fast.should be_false
|
15
|
+
describe '#initialize' do
|
16
|
+
let(:compressor) { Backup::Compressor::Gzip.new }
|
14
17
|
|
15
|
-
|
16
|
-
compressor.best.should be_false
|
17
|
-
compressor.fast.should be_false
|
18
|
+
after { Backup::Compressor::Gzip.clear_defaults! }
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
it 'should load pre-configured defaults' do
|
21
|
+
Backup::Compressor::Gzip.any_instance.expects(:load_defaults!)
|
22
|
+
compressor
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when no pre-configured defaults have been set' do
|
26
|
+
it 'should use default values' do
|
27
|
+
compressor.level.should be_false
|
28
|
+
|
29
|
+
compressor.instance_variable_get(:@cmd).should == 'gzip'
|
30
|
+
compressor.instance_variable_get(:@ext).should == '.gz'
|
22
31
|
end
|
23
|
-
Backup::Configuration::Compressor::Gzip.best.should be_true
|
24
|
-
Backup::Configuration::Compressor::Gzip.fast.should be_true
|
25
32
|
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
it 'should use the values given' do
|
34
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
35
|
+
c.level = 5
|
36
|
+
end
|
37
|
+
compressor.level.should == 5
|
29
38
|
|
30
|
-
|
31
|
-
|
39
|
+
compressor.instance_variable_get(:@cmd).should == 'gzip -5'
|
40
|
+
compressor.instance_variable_get(:@ext).should == '.gz'
|
32
41
|
end
|
33
|
-
|
34
|
-
compressor.fast.should be_true
|
42
|
+
end # context 'when no pre-configured defaults have been set'
|
35
43
|
|
36
|
-
|
37
|
-
|
44
|
+
context 'when pre-configured defaults have been set' do
|
45
|
+
before do
|
46
|
+
Backup::Compressor::Gzip.defaults do |c|
|
47
|
+
c.level = 7
|
48
|
+
end
|
38
49
|
end
|
39
|
-
compressor.best.should be_true
|
40
|
-
compressor.fast.should be_false
|
41
|
-
end
|
42
|
-
end # describe 'setting configuration defaults'
|
43
50
|
|
44
|
-
|
45
|
-
|
46
|
-
compressor.expects(:log!)
|
47
|
-
compressor.expects(:utility).with(:gzip).returns('gzip')
|
48
|
-
end
|
51
|
+
it 'should use pre-configured defaults' do
|
52
|
+
compressor.level.should == 7
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
compressor.compress_with do |cmd, ext|
|
53
|
-
cmd.should == 'gzip --best'
|
54
|
-
ext.should == '.gz'
|
54
|
+
compressor.instance_variable_get(:@cmd).should == 'gzip -7'
|
55
|
+
compressor.instance_variable_get(:@ext).should == '.gz'
|
55
56
|
end
|
56
|
-
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
it 'should override pre-configured defaults' do
|
59
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
60
|
+
c.level = 6
|
61
|
+
end
|
62
|
+
compressor.level.should == 6
|
63
|
+
|
64
|
+
compressor.instance_variable_get(:@cmd).should == 'gzip -6'
|
65
|
+
compressor.instance_variable_get(:@ext).should == '.gz'
|
63
66
|
end
|
64
|
-
end
|
67
|
+
end # context 'when pre-configured defaults have been set'
|
68
|
+
end # describe '#initialize'
|
69
|
+
|
70
|
+
describe 'deprecations' do
|
71
|
+
describe 'fast and best options' do
|
72
|
+
context 'when only the fast option is used' do
|
73
|
+
before do
|
74
|
+
Backup::Logger.expects(:warn).with(
|
75
|
+
instance_of(Backup::Errors::ConfigurationError)
|
76
|
+
)
|
77
|
+
end
|
65
78
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
79
|
+
context 'when set to true' do
|
80
|
+
it 'should log a warning and set `level` to 1' do
|
81
|
+
Backup::Logger.expects(:warn).with(
|
82
|
+
"Backup::Compressor::Gzip.level is being set to '1'"
|
83
|
+
)
|
84
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
85
|
+
c.fast = true
|
86
|
+
end
|
87
|
+
compressor.level.should be(1)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when set to false' do
|
92
|
+
it 'should only log a warning' do
|
93
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
94
|
+
c.fast = false
|
95
|
+
end
|
96
|
+
compressor.level.should be_false
|
97
|
+
end
|
98
|
+
end
|
72
99
|
end
|
73
|
-
end
|
74
100
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
101
|
+
context 'when only the best option is used' do
|
102
|
+
before do
|
103
|
+
Backup::Logger.expects(:warn).with(
|
104
|
+
instance_of(Backup::Errors::ConfigurationError)
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when set to true' do
|
109
|
+
it 'should log a warning and set `level` to 1' do
|
110
|
+
Backup::Logger.expects(:warn).with(
|
111
|
+
"Backup::Compressor::Gzip.level is being set to '9'"
|
112
|
+
)
|
113
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
114
|
+
c.best = true
|
115
|
+
end
|
116
|
+
compressor.level.should be(9)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when set to false' do
|
121
|
+
it 'should only log a warning' do
|
122
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
123
|
+
c.best = false
|
124
|
+
end
|
125
|
+
compressor.level.should be_false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
79
129
|
end
|
80
|
-
end
|
81
|
-
end # describe '#compress_with'
|
82
130
|
|
131
|
+
context 'when both fast and best options are used' do
|
132
|
+
before do
|
133
|
+
Backup::Logger.expects(:warn).twice.with(
|
134
|
+
instance_of(Backup::Errors::ConfigurationError)
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'when both are set true' do
|
139
|
+
context 'when fast is set first' do
|
140
|
+
it 'should cause the best option to be set' do
|
141
|
+
Backup::Logger.expects(:warn).with(
|
142
|
+
"Backup::Compressor::Gzip.level is being set to '1'"
|
143
|
+
)
|
144
|
+
Backup::Logger.expects(:warn).with(
|
145
|
+
"Backup::Compressor::Gzip.level is being set to '9'"
|
146
|
+
)
|
147
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
148
|
+
c.fast = true
|
149
|
+
c.best = true
|
150
|
+
end
|
151
|
+
compressor.level.should == 9
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'when best is set first' do
|
156
|
+
it 'should cause the fast option to be set' do
|
157
|
+
Backup::Logger.expects(:warn).with(
|
158
|
+
"Backup::Compressor::Gzip.level is being set to '1'"
|
159
|
+
)
|
160
|
+
Backup::Logger.expects(:warn).with(
|
161
|
+
"Backup::Compressor::Gzip.level is being set to '9'"
|
162
|
+
)
|
163
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
164
|
+
c.best = true
|
165
|
+
c.fast = true
|
166
|
+
end
|
167
|
+
compressor.level.should == 1
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'when only one is set true' do
|
173
|
+
context 'when fast is set true before best' do
|
174
|
+
it 'should cause the fast option to be set' do
|
175
|
+
Backup::Logger.expects(:warn).with(
|
176
|
+
"Backup::Compressor::Gzip.level is being set to '1'"
|
177
|
+
)
|
178
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
179
|
+
c.fast = true
|
180
|
+
c.best = false
|
181
|
+
end
|
182
|
+
compressor.level.should == 1
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
context 'when fast is set true after best' do
|
187
|
+
it 'should cause the fast option to be set' do
|
188
|
+
Backup::Logger.expects(:warn).with(
|
189
|
+
"Backup::Compressor::Gzip.level is being set to '1'"
|
190
|
+
)
|
191
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
192
|
+
c.best = false
|
193
|
+
c.fast = true
|
194
|
+
end
|
195
|
+
compressor.level.should == 1
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'when best is set true before fast' do
|
200
|
+
it 'should cause the best option to be set' do
|
201
|
+
Backup::Logger.expects(:warn).with(
|
202
|
+
"Backup::Compressor::Gzip.level is being set to '9'"
|
203
|
+
)
|
204
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
205
|
+
c.best = true
|
206
|
+
c.fast = false
|
207
|
+
end
|
208
|
+
compressor.level.should == 9
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'when best is set true after fast' do
|
213
|
+
it 'should cause the best option to be set' do
|
214
|
+
Backup::Logger.expects(:warn).with(
|
215
|
+
"Backup::Compressor::Gzip.level is being set to '9'"
|
216
|
+
)
|
217
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
218
|
+
c.fast = false
|
219
|
+
c.best = true
|
220
|
+
end
|
221
|
+
compressor.level.should == 9
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context 'when both are set false' do
|
227
|
+
it 'should only issue the two warnings' do
|
228
|
+
compressor = Backup::Compressor::Gzip.new do |c|
|
229
|
+
c.fast = false
|
230
|
+
c.best = false
|
231
|
+
end
|
232
|
+
compressor.level.should be_false
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end # describe 'fast and best options'
|
237
|
+
end # describe 'deprecations'
|
83
238
|
end
|
@@ -3,52 +3,83 @@
|
|
3
3
|
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
4
|
|
5
5
|
describe Backup::Compressor::Lzma do
|
6
|
-
|
6
|
+
before do
|
7
|
+
Backup::Compressor::Lzma.any_instance.stubs(:utility).returns('lzma')
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
it 'should be a subclass of Compressor::Base' do
|
11
|
+
Backup::Compressor::Lzma.
|
12
|
+
superclass.should == Backup::Compressor::Base
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
Backup::Configuration::Compressor::Lzma.fast.should be_false
|
15
|
+
describe '#initialize' do
|
16
|
+
let(:compressor) { Backup::Compressor::Lzma.new }
|
14
17
|
|
15
|
-
|
16
|
-
compressor.best.should be_false
|
17
|
-
compressor.fast.should be_false
|
18
|
+
after { Backup::Compressor::Lzma.clear_defaults! }
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
it 'should load pre-configured defaults' do
|
21
|
+
Backup::Compressor::Lzma.any_instance.expects(:load_defaults!)
|
22
|
+
compressor
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when no pre-configured defaults have been set' do
|
26
|
+
it 'should use default values' do
|
27
|
+
compressor.best.should be_false
|
28
|
+
compressor.fast.should be_false
|
22
29
|
end
|
23
|
-
Backup::Configuration::Compressor::Lzma.best.should be_true
|
24
|
-
Backup::Configuration::Compressor::Lzma.fast.should be_true
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
it 'should use the values given' do
|
32
|
+
compressor = Backup::Compressor::Lzma.new do |c|
|
33
|
+
c.best = true
|
34
|
+
c.fast = true
|
35
|
+
end
|
29
36
|
|
30
|
-
|
31
|
-
|
37
|
+
compressor.best.should be_true
|
38
|
+
compressor.fast.should be_true
|
32
39
|
end
|
33
|
-
|
34
|
-
compressor.fast.should be_true
|
40
|
+
end # context 'when no pre-configured defaults have been set'
|
35
41
|
|
36
|
-
|
37
|
-
|
42
|
+
context 'when pre-configured defaults have been set' do
|
43
|
+
before do
|
44
|
+
Backup::Compressor::Lzma.defaults do |c|
|
45
|
+
c.best = true
|
46
|
+
c.fast = true
|
47
|
+
end
|
38
48
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
49
|
+
|
50
|
+
it 'should use pre-configured defaults' do
|
51
|
+
compressor.best.should be_true
|
52
|
+
compressor.fast.should be_true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should override pre-configured defaults' do
|
56
|
+
compressor = Backup::Compressor::Lzma.new do |c|
|
57
|
+
c.best = false
|
58
|
+
c.fast = false
|
59
|
+
end
|
60
|
+
|
61
|
+
compressor.best.should be_false
|
62
|
+
compressor.fast.should be_false
|
63
|
+
end
|
64
|
+
end # context 'when pre-configured defaults have been set'
|
65
|
+
end # describe '#initialize'
|
43
66
|
|
44
67
|
describe '#compress_with' do
|
45
68
|
before do
|
46
|
-
|
47
|
-
|
69
|
+
Backup::Compressor::Lzma.any_instance.expects(:log!)
|
70
|
+
|
71
|
+
Backup::Logger.expects(:warn).with do |msg|
|
72
|
+
msg.should match(
|
73
|
+
/\[DEPRECATION WARNING\]\n Compressor::Lzma is being deprecated/
|
74
|
+
)
|
75
|
+
end
|
48
76
|
end
|
49
77
|
|
50
78
|
it 'should yield with the --best option' do
|
51
|
-
compressor
|
79
|
+
compressor = Backup::Compressor::Lzma.new do |c|
|
80
|
+
c.best = true
|
81
|
+
end
|
82
|
+
|
52
83
|
compressor.compress_with do |cmd, ext|
|
53
84
|
cmd.should == 'lzma --best'
|
54
85
|
ext.should == '.lzma'
|
@@ -56,28 +87,37 @@ describe Backup::Compressor::Lzma do
|
|
56
87
|
end
|
57
88
|
|
58
89
|
it 'should yield with the --fast option' do
|
59
|
-
compressor
|
90
|
+
compressor = Backup::Compressor::Lzma.new do |c|
|
91
|
+
c.fast = true
|
92
|
+
end
|
93
|
+
|
60
94
|
compressor.compress_with do |cmd, ext|
|
61
95
|
cmd.should == 'lzma --fast'
|
62
96
|
ext.should == '.lzma'
|
63
97
|
end
|
64
98
|
end
|
65
99
|
|
66
|
-
it 'should
|
67
|
-
compressor
|
68
|
-
|
100
|
+
it 'should prefer the --best option over --fast' do
|
101
|
+
compressor = Backup::Compressor::Lzma.new do |c|
|
102
|
+
c.best = true
|
103
|
+
c.fast = true
|
104
|
+
end
|
105
|
+
|
69
106
|
compressor.compress_with do |cmd, ext|
|
70
|
-
cmd.should == 'lzma --best
|
107
|
+
cmd.should == 'lzma --best'
|
71
108
|
ext.should == '.lzma'
|
72
109
|
end
|
73
110
|
end
|
74
111
|
|
75
112
|
it 'should yield with no options' do
|
113
|
+
compressor = Backup::Compressor::Lzma.new
|
114
|
+
|
76
115
|
compressor.compress_with do |cmd, ext|
|
77
116
|
cmd.should == 'lzma'
|
78
117
|
ext.should == '.lzma'
|
79
118
|
end
|
80
119
|
end
|
120
|
+
|
81
121
|
end # describe '#compress_with'
|
82
122
|
|
83
123
|
end
|
@@ -3,66 +3,90 @@
|
|
3
3
|
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
4
|
|
5
5
|
describe Backup::Compressor::Pbzip2 do
|
6
|
-
|
6
|
+
before do
|
7
|
+
Backup::Compressor::Pbzip2.any_instance.stubs(:utility).returns('pbzip2')
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
it 'should be a subclass of Compressor::Base' do
|
11
|
+
Backup::Compressor::Pbzip2.
|
12
|
+
superclass.should == Backup::Compressor::Base
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
Backup::Configuration::Compressor::Pbzip2.fast.should be_false
|
14
|
-
Backup::Configuration::Compressor::Pbzip2.processors.should be_false
|
15
|
+
describe '#initialize' do
|
16
|
+
let(:compressor) { Backup::Compressor::Pbzip2.new }
|
15
17
|
|
16
|
-
|
17
|
-
compressor.best.should be_false
|
18
|
-
compressor.fast.should be_false
|
19
|
-
compressor.processors.should be_false
|
18
|
+
after { Backup::Compressor::Pbzip2.clear_defaults! }
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
it 'should load pre-configured defaults' do
|
21
|
+
Backup::Compressor::Pbzip2.any_instance.expects(:load_defaults!)
|
22
|
+
compressor
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when no pre-configured defaults have been set' do
|
26
|
+
it 'should use default values' do
|
27
|
+
compressor.best.should be_false
|
28
|
+
compressor.fast.should be_false
|
29
|
+
compressor.processors.should be_false
|
25
30
|
end
|
26
|
-
Backup::Configuration::Compressor::Pbzip2.best.should be_true
|
27
|
-
Backup::Configuration::Compressor::Pbzip2.fast.should be_true
|
28
|
-
Backup::Configuration::Compressor::Pbzip2.processors.should == 2
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
it 'should use the values given' do
|
33
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
34
|
+
c.best = true
|
35
|
+
c.fast = true
|
36
|
+
c.processors = 2
|
37
|
+
end
|
34
38
|
|
35
|
-
|
36
|
-
|
39
|
+
compressor.best.should be_true
|
40
|
+
compressor.fast.should be_true
|
41
|
+
compressor.processors.should == 2
|
42
|
+
end
|
43
|
+
end # context 'when no pre-configured defaults have been set'
|
44
|
+
|
45
|
+
context 'when pre-configured defaults have been set' do
|
46
|
+
before do
|
47
|
+
Backup::Compressor::Pbzip2.defaults do |c|
|
48
|
+
c.best = true
|
49
|
+
c.fast = true
|
50
|
+
c.processors = 2
|
51
|
+
end
|
37
52
|
end
|
38
|
-
compressor.best.should be_false
|
39
|
-
compressor.fast.should be_true
|
40
|
-
compressor.processors.should == 2
|
41
53
|
|
42
|
-
|
43
|
-
|
54
|
+
it 'should use pre-configured defaults' do
|
55
|
+
compressor.best.should be_true
|
56
|
+
compressor.fast.should be_true
|
57
|
+
compressor.processors.should == 2
|
44
58
|
end
|
45
|
-
compressor.best.should be_true
|
46
|
-
compressor.fast.should be_false
|
47
|
-
compressor.processors.should == 2
|
48
59
|
|
49
|
-
|
50
|
-
|
60
|
+
it 'should override pre-configured defaults' do
|
61
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
62
|
+
c.best = false
|
63
|
+
c.fast = false
|
64
|
+
c.processors = 4
|
65
|
+
end
|
66
|
+
|
67
|
+
compressor.best.should be_false
|
68
|
+
compressor.fast.should be_false
|
69
|
+
compressor.processors.should == 4
|
51
70
|
end
|
52
|
-
|
53
|
-
|
54
|
-
compressor.processors.should be_false
|
55
|
-
end
|
56
|
-
end # describe 'setting configuration defaults'
|
71
|
+
end # context 'when pre-configured defaults have been set'
|
72
|
+
end # describe '#initialize'
|
57
73
|
|
58
74
|
describe '#compress_with' do
|
59
75
|
before do
|
60
|
-
|
61
|
-
|
76
|
+
Backup::Compressor::Pbzip2.any_instance.expects(:log!)
|
77
|
+
|
78
|
+
Backup::Logger.expects(:warn).with do |msg|
|
79
|
+
msg.should match(
|
80
|
+
/\[DEPRECATION WARNING\]\n Compressor::Pbzip2 is being deprecated/
|
81
|
+
)
|
82
|
+
end
|
62
83
|
end
|
63
84
|
|
64
85
|
it 'should yield with the --best option' do
|
65
|
-
compressor
|
86
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
87
|
+
c.best = true
|
88
|
+
end
|
89
|
+
|
66
90
|
compressor.compress_with do |cmd, ext|
|
67
91
|
cmd.should == 'pbzip2 --best'
|
68
92
|
ext.should == '.bz2'
|
@@ -70,7 +94,10 @@ describe Backup::Compressor::Pbzip2 do
|
|
70
94
|
end
|
71
95
|
|
72
96
|
it 'should yield with the --fast option' do
|
73
|
-
compressor
|
97
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
98
|
+
c.fast = true
|
99
|
+
end
|
100
|
+
|
74
101
|
compressor.compress_with do |cmd, ext|
|
75
102
|
cmd.should == 'pbzip2 --fast'
|
76
103
|
ext.should == '.bz2'
|
@@ -78,25 +105,34 @@ describe Backup::Compressor::Pbzip2 do
|
|
78
105
|
end
|
79
106
|
|
80
107
|
it 'should yield with the -p option' do
|
81
|
-
compressor
|
108
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
109
|
+
c.processors = 2
|
110
|
+
end
|
111
|
+
|
82
112
|
compressor.compress_with do |cmd, ext|
|
83
113
|
cmd.should == 'pbzip2 -p2'
|
84
114
|
ext.should == '.bz2'
|
85
115
|
end
|
86
116
|
end
|
87
117
|
|
88
|
-
it 'should
|
89
|
-
compressor
|
90
|
-
|
118
|
+
it 'should prefer the --best option over --fast' do
|
119
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
120
|
+
c.best = true
|
121
|
+
c.fast = true
|
122
|
+
end
|
123
|
+
|
91
124
|
compressor.compress_with do |cmd, ext|
|
92
|
-
cmd.should == 'pbzip2 --best
|
125
|
+
cmd.should == 'pbzip2 --best'
|
93
126
|
ext.should == '.bz2'
|
94
127
|
end
|
95
128
|
end
|
96
129
|
|
97
130
|
it 'should yield with the --best and -p options' do
|
98
|
-
compressor
|
99
|
-
|
131
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
132
|
+
c.best = true
|
133
|
+
c.processors = 2
|
134
|
+
end
|
135
|
+
|
100
136
|
compressor.compress_with do |cmd, ext|
|
101
137
|
cmd.should == 'pbzip2 --best -p2'
|
102
138
|
ext.should == '.bz2'
|
@@ -104,8 +140,11 @@ describe Backup::Compressor::Pbzip2 do
|
|
104
140
|
end
|
105
141
|
|
106
142
|
it 'should yield with the --fast and -p options' do
|
107
|
-
compressor
|
108
|
-
|
143
|
+
compressor = Backup::Compressor::Pbzip2.new do |c|
|
144
|
+
c.fast = true
|
145
|
+
c.processors = 2
|
146
|
+
end
|
147
|
+
|
109
148
|
compressor.compress_with do |cmd, ext|
|
110
149
|
cmd.should == 'pbzip2 --fast -p2'
|
111
150
|
ext.should == '.bz2'
|
@@ -113,6 +152,8 @@ describe Backup::Compressor::Pbzip2 do
|
|
113
152
|
end
|
114
153
|
|
115
154
|
it 'should yield with no options' do
|
155
|
+
compressor = Backup::Compressor::Pbzip2.new
|
156
|
+
|
116
157
|
compressor.compress_with do |cmd, ext|
|
117
158
|
cmd.should == 'pbzip2'
|
118
159
|
ext.should == '.bz2'
|