dump 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -15
- data/.rubocop_todo.yml +1 -1
- data/Gemfile +6 -1
- data/LICENSE.txt +1 -1
- data/README.markdown +2 -2
- data/dump.gemspec +2 -2
- data/lib/dump.rb +86 -2
- data/lib/{dump_rake/archive_tar_minitar_fix.rb → dump/archive_tar_minitar.rb} +0 -0
- data/lib/{dump_rake → dump}/assets.rb +6 -4
- data/lib/dump/capistrano/v2.rb +34 -34
- data/lib/{dump_rake → dump}/continious_timeout.rb +1 -1
- data/lib/{dump_rake → dump}/env.rb +4 -4
- data/lib/{dump_rake → dump}/env/filter.rb +1 -1
- data/lib/dump/rails_root.rb +19 -0
- data/lib/{dump_rake/dump_reader.rb → dump/reader.rb} +25 -17
- data/lib/{dump_rake/dump.rb → dump/snapshot.rb} +9 -5
- data/lib/{dump_rake → dump}/table_manipulation.rb +28 -14
- data/lib/{dump_rake/dump_writer.rb → dump/writer.rb} +13 -5
- data/lib/tasks/assets.rake +4 -4
- data/lib/tasks/dump.rake +10 -10
- data/script/update_readme +3 -3
- data/spec/cycle_spec.rb +78 -84
- data/spec/{lib/dump_rake → dump}/env/filter_spec.rb +14 -14
- data/spec/dump/env_spec.rb +139 -0
- data/spec/{lib/dump_rake → dump}/rails_root_spec.rb +11 -13
- data/spec/{lib/dump_rake/dump_reader_spec.rb → dump/reader_spec.rb} +89 -89
- data/spec/dump/snapshot_spec.rb +290 -0
- data/spec/{lib/dump_rake → dump}/table_manipulation_spec.rb +54 -55
- data/spec/{lib/dump_rake/dump_writer_spec.rb → dump/writer_spec.rb} +41 -42
- data/spec/dump_spec.rb +327 -0
- data/spec/recipes/dump_spec.rb +92 -93
- data/spec/spec_helper.rb +0 -3
- data/spec/tasks/assets_spec.rb +16 -15
- data/spec/tasks/dump_spec.rb +30 -29
- metadata +75 -98
- data/.autotest +0 -13
- data/lib/dump_rake.rb +0 -94
- data/lib/dump_rake/rails_root.rb +0 -13
- data/spec/lib/dump_rake/dump_spec.rb +0 -289
- data/spec/lib/dump_rake/env_spec.rb +0 -139
- data/spec/lib/dump_rake_spec.rb +0 -326
- data/spec/spec.opts +0 -4
data/spec/recipes/dump_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'dump'
|
2
3
|
require 'capistrano'
|
3
4
|
|
4
5
|
describe 'cap dump' do
|
@@ -11,21 +12,21 @@ describe 'cap dump' do
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def all_dictionary_variables
|
14
|
-
|
15
|
+
Dump::Env::DICTIONARY.each_with_object({}) do |(key, value), filled_env|
|
15
16
|
filled_env[key] = value.join(' ')
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.test_passing_environment_variables(place, command, command_strings, options = {})
|
20
|
-
|
21
|
+
Dump::Env.variable_names_for_command(command).each do |variable|
|
21
22
|
command_string = command_strings[variable]
|
22
|
-
|
23
|
-
it "
|
23
|
+
Dump::Env::DICTIONARY[variable].each do |name|
|
24
|
+
it "passes #{variable} if it is set through environment variable #{name}" do
|
24
25
|
violated 'command_string not specified' unless command_string
|
25
26
|
full_command_string = command_string
|
26
27
|
full_command_string = "cd #{@remote_path}; #{command_string}" if place == :remote
|
27
28
|
expect(@cap.dump).to receive(:"run_#{place}").with(full_command_string).and_return(options[:return_value] || '')
|
28
|
-
|
29
|
+
Dump::Env.with_env name => options[:value] || 'some data' do
|
29
30
|
cap_task = options[:cap_task] || "dump:#{place}:#{command}"
|
30
31
|
grab_output{ @cap.find_and_execute_task(cap_task) }
|
31
32
|
end
|
@@ -35,12 +36,11 @@ describe 'cap dump' do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
describe :dump_command do
|
38
|
-
|
39
|
-
it 'should return escaped string' do
|
39
|
+
it 'returns escaped string' do
|
40
40
|
expect(@cap.dump.dump_command(:hello, :rake => 'rake', 'x x' => 'a b')).to eq('rake -s dump:hello x\\ x\\=a\\ b')
|
41
41
|
end
|
42
42
|
|
43
|
-
it '
|
43
|
+
it 'returns escaped string for complex rake invocation command' do
|
44
44
|
expect(@cap.dump.dump_command(:hello, :rake => 'bundler exec rake', 'x x' => 'a b')).to eq('bundler exec rake -s dump:hello x\\ x\\=a\\ b')
|
45
45
|
end
|
46
46
|
end
|
@@ -53,20 +53,19 @@ describe 'cap dump' do
|
|
53
53
|
[:up, :down].each do |direction|
|
54
54
|
describe direction do
|
55
55
|
describe 'if method not set' do
|
56
|
-
|
57
|
-
it 'should call got_rsync?' do
|
56
|
+
it 'calls got_rsync?' do
|
58
57
|
expect(@cap.dump).to receive(:got_rsync?)
|
59
58
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
60
59
|
end
|
61
60
|
|
62
61
|
describe 'if got_rsync?' do
|
63
|
-
it '
|
62
|
+
it 'uses rsync' do
|
64
63
|
allow(@cap.dump).to receive(:got_rsync?).and_return(true)
|
65
64
|
expect(@cap.dump).to receive(:do_transfer_via).with(:rsync, direction, 'a.tgz', 'b.tgz')
|
66
65
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
67
66
|
end
|
68
67
|
|
69
|
-
it '
|
68
|
+
it 'raises if rsync fails' do
|
70
69
|
allow(@cap.dump).to receive(:got_rsync?).and_return(true)
|
71
70
|
expect(@cap.dump).to receive(:do_transfer_via).with(:rsync, direction, 'a.tgz', 'b.tgz').and_raise('problem using rsync')
|
72
71
|
expect do
|
@@ -76,20 +75,20 @@ describe 'cap dump' do
|
|
76
75
|
end
|
77
76
|
|
78
77
|
describe 'unless got_rsync?' do
|
79
|
-
it '
|
78
|
+
it 'tries sftp' do
|
80
79
|
allow(@cap.dump).to receive(:got_rsync?).and_return(false)
|
81
80
|
expect(@cap.dump).to receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz')
|
82
81
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
83
82
|
end
|
84
83
|
|
85
|
-
it '
|
84
|
+
it 'tries scp after sftp' do
|
86
85
|
allow(@cap.dump).to receive(:got_rsync?).and_return(false)
|
87
86
|
expect(@cap.dump).to receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
|
88
87
|
expect(@cap.dump).to receive(:do_transfer_via).with(:scp, direction, 'a.tgz', 'b.tgz')
|
89
88
|
grab_output{ @cap.dump.do_transfer(direction, 'a.tgz', 'b.tgz') }
|
90
89
|
end
|
91
90
|
|
92
|
-
it '
|
91
|
+
it 'does not rescue if scp also fails' do
|
93
92
|
allow(@cap.dump).to receive(:got_rsync?).and_return(false)
|
94
93
|
expect(@cap.dump).to receive(:do_transfer_via).with(:sftp, direction, 'a.tgz', 'b.tgz').and_raise('problem using sftp')
|
95
94
|
expect(@cap.dump).to receive(:do_transfer_via).with(:scp, direction, 'a.tgz', 'b.tgz').and_raise('problem using scp')
|
@@ -104,13 +103,13 @@ describe 'cap dump' do
|
|
104
103
|
end
|
105
104
|
|
106
105
|
describe 'local' do
|
107
|
-
it '
|
106
|
+
it 'calls local:create' do
|
108
107
|
expect(@cap.dump.local).to receive(:create).and_return('')
|
109
108
|
@cap.find_and_execute_task('dump:local')
|
110
109
|
end
|
111
110
|
|
112
111
|
describe 'versions' do
|
113
|
-
it '
|
112
|
+
it 'calls local rake task' do
|
114
113
|
expect(@cap.dump).to receive(:run_local).with('rake -s dump:versions SHOW_SIZE\\=true').and_return('')
|
115
114
|
@cap.find_and_execute_task('dump:local:versions')
|
116
115
|
end
|
@@ -121,7 +120,7 @@ describe 'cap dump' do
|
|
121
120
|
:summary => 'rake -s dump:versions SHOW_SIZE\\=true SUMMARY\\=some\\ data',
|
122
121
|
})
|
123
122
|
|
124
|
-
it '
|
123
|
+
it 'prints result of rake task' do
|
125
124
|
allow(@cap.dump).to receive(:run_local).and_return(" 123M\t123123.tgz\n")
|
126
125
|
expect(grab_output do
|
127
126
|
@cap.find_and_execute_task('dump:local:versions')
|
@@ -130,7 +129,7 @@ describe 'cap dump' do
|
|
130
129
|
end
|
131
130
|
|
132
131
|
describe 'cleanup' do
|
133
|
-
it '
|
132
|
+
it 'calls local rake task' do
|
134
133
|
expect(@cap.dump).to receive(:run_local).with('rake -s dump:cleanup').and_return('')
|
135
134
|
@cap.find_and_execute_task('dump:local:cleanup')
|
136
135
|
end
|
@@ -141,7 +140,7 @@ describe 'cap dump' do
|
|
141
140
|
:leave => 'rake -s dump:cleanup LEAVE\\=some\\ data',
|
142
141
|
})
|
143
142
|
|
144
|
-
it '
|
143
|
+
it 'prints result of rake task' do
|
145
144
|
allow(@cap.dump).to receive(:run_local).and_return("123123.tgz\n")
|
146
145
|
expect(grab_output do
|
147
146
|
@cap.find_and_execute_task('dump:local:cleanup')
|
@@ -150,24 +149,24 @@ describe 'cap dump' do
|
|
150
149
|
end
|
151
150
|
|
152
151
|
describe 'create' do
|
153
|
-
it '
|
152
|
+
it 'raises if dump creation fails' do
|
154
153
|
expect(@cap.dump).to receive(:run_local).with('rake -s dump:create TAGS\\=local').and_return('')
|
155
154
|
expect do
|
156
155
|
@cap.find_and_execute_task('dump:local:create')
|
157
156
|
end.to raise_error('Failed creating dump')
|
158
157
|
end
|
159
158
|
|
160
|
-
it '
|
159
|
+
it 'calls local rake task with tag local' do
|
161
160
|
expect(@cap.dump).to receive(:run_local).with('rake -s dump:create TAGS\\=local').and_return('123.tgz')
|
162
161
|
grab_output do
|
163
162
|
@cap.find_and_execute_task('dump:local:create')
|
164
163
|
end
|
165
164
|
end
|
166
165
|
|
167
|
-
it '
|
166
|
+
it 'calls local rake task with additional tag local' do
|
168
167
|
expect(@cap.dump).to receive(:run_local).with('rake -s dump:create TAGS\\=local,photos').and_return('123.tgz')
|
169
168
|
grab_output do
|
170
|
-
|
169
|
+
Dump::Env.with_env :tags => 'photos' do
|
171
170
|
@cap.find_and_execute_task('dump:local:create')
|
172
171
|
end
|
173
172
|
end
|
@@ -180,14 +179,14 @@ describe 'cap dump' do
|
|
180
179
|
:assets => 'rake -s dump:create ASSETS\\=some\\ data TAGS\\=local',
|
181
180
|
}, :return_value => '123.tgz')
|
182
181
|
|
183
|
-
it '
|
182
|
+
it 'prints result of rake task' do
|
184
183
|
allow(@cap.dump).to receive(:run_local).and_return("123123.tgz\n")
|
185
184
|
expect(grab_output do
|
186
185
|
@cap.find_and_execute_task('dump:local:create')
|
187
186
|
end[:stdout]).to eq("123123.tgz\n")
|
188
187
|
end
|
189
188
|
|
190
|
-
it '
|
189
|
+
it 'returns stripped result of rake task' do
|
191
190
|
allow(@cap.dump).to receive(:run_local).and_return("123123.tgz\n")
|
192
191
|
grab_output do
|
193
192
|
expect(@cap.find_and_execute_task('dump:local:create')).to eq('123123.tgz')
|
@@ -196,7 +195,7 @@ describe 'cap dump' do
|
|
196
195
|
end
|
197
196
|
|
198
197
|
describe 'restore' do
|
199
|
-
it '
|
198
|
+
it 'calls local rake task' do
|
200
199
|
expect(@cap.dump).to receive(:run_local).with('rake -s dump:restore')
|
201
200
|
@cap.find_and_execute_task('dump:local:restore')
|
202
201
|
end
|
@@ -212,7 +211,7 @@ describe 'cap dump' do
|
|
212
211
|
end
|
213
212
|
|
214
213
|
describe 'upload' do
|
215
|
-
it '
|
214
|
+
it 'runs rake versions to get avaliable versions' do
|
216
215
|
expect(@cap.dump).to receive(:run_local).with('rake -s dump:versions').and_return('')
|
217
216
|
@cap.find_and_execute_task('dump:local:upload')
|
218
217
|
end
|
@@ -224,19 +223,19 @@ describe 'cap dump' do
|
|
224
223
|
:transfer_via => 'rake -s dump:versions', # tranfer_via is used internally
|
225
224
|
}, :cap_task => 'dump:local:upload')
|
226
225
|
|
227
|
-
it '
|
226
|
+
it 'does not upload anything if there are no versions avaliable' do
|
228
227
|
allow(@cap.dump).to receive(:run_local).and_return('')
|
229
228
|
expect(@cap.dump).not_to receive(:do_transfer)
|
230
229
|
@cap.find_and_execute_task('dump:local:upload')
|
231
230
|
end
|
232
231
|
|
233
|
-
it '
|
232
|
+
it 'transfers latest version dump' do
|
234
233
|
allow(@cap.dump).to receive(:run_local).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
235
234
|
expect(@cap.dump).to receive(:do_transfer).with(:up, 'dump/300.tgz', "#{@remote_path}/dump/300.tgz")
|
236
235
|
@cap.find_and_execute_task('dump:local:upload')
|
237
236
|
end
|
238
237
|
|
239
|
-
it '
|
238
|
+
it 'handles extra spaces around file names' do
|
240
239
|
allow(@cap.dump).to receive(:run_local).and_return("\r\n\r\n\r 100.tgz \r\n\r\n\r 200.tgz \r\n\r\n\r 300.tgz \r\n\r\n\r ")
|
241
240
|
expect(@cap.dump).to receive(:do_transfer).with(:up, 'dump/300.tgz', "#{@remote_path}/dump/300.tgz")
|
242
241
|
@cap.find_and_execute_task('dump:local:upload')
|
@@ -245,13 +244,13 @@ describe 'cap dump' do
|
|
245
244
|
end
|
246
245
|
|
247
246
|
describe 'remote' do
|
248
|
-
it '
|
247
|
+
it 'calls remote:create' do
|
249
248
|
expect(@cap.dump.remote).to receive(:create).and_return('')
|
250
249
|
@cap.find_and_execute_task('dump:remote')
|
251
250
|
end
|
252
251
|
|
253
252
|
describe 'versions' do
|
254
|
-
it '
|
253
|
+
it 'calls remote rake task' do
|
255
254
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
|
256
255
|
@cap.find_and_execute_task('dump:remote:versions')
|
257
256
|
end
|
@@ -262,14 +261,14 @@ describe 'cap dump' do
|
|
262
261
|
:summary => 'rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true SUMMARY\\=some\\ data',
|
263
262
|
})
|
264
263
|
|
265
|
-
it '
|
264
|
+
it 'prints result of rake task' do
|
266
265
|
allow(@cap.dump).to receive(:run_remote).and_return(" 123M\t123123.tgz\n")
|
267
266
|
expect(grab_output do
|
268
267
|
@cap.find_and_execute_task('dump:remote:versions')
|
269
268
|
end[:stdout]).to eq(" 123M\t123123.tgz\n")
|
270
269
|
end
|
271
270
|
|
272
|
-
it '
|
271
|
+
it 'uses custom rake binary' do
|
273
272
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
274
273
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production SHOW_SIZE\\=true").and_return('')
|
275
274
|
@cap.find_and_execute_task('dump:remote:versions')
|
@@ -277,7 +276,7 @@ describe 'cap dump' do
|
|
277
276
|
end
|
278
277
|
|
279
278
|
describe 'cleanup' do
|
280
|
-
it '
|
279
|
+
it 'calls remote rake task' do
|
281
280
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
282
281
|
@cap.find_and_execute_task('dump:remote:cleanup')
|
283
282
|
end
|
@@ -288,14 +287,14 @@ describe 'cap dump' do
|
|
288
287
|
:leave => 'rake -s dump:cleanup LEAVE\\=some\\ data PROGRESS_TTY\\=\\+ RAILS_ENV\\=production',
|
289
288
|
})
|
290
289
|
|
291
|
-
it '
|
290
|
+
it 'prints result of rake task' do
|
292
291
|
allow(@cap.dump).to receive(:run_remote).and_return("123123.tgz\n")
|
293
292
|
expect(grab_output do
|
294
293
|
@cap.find_and_execute_task('dump:remote:cleanup')
|
295
294
|
end[:stdout]).to eq("123123.tgz\n")
|
296
295
|
end
|
297
296
|
|
298
|
-
it '
|
297
|
+
it 'uses custom rake binary' do
|
299
298
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
300
299
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:cleanup PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
301
300
|
@cap.find_and_execute_task('dump:remote:cleanup')
|
@@ -303,30 +302,30 @@ describe 'cap dump' do
|
|
303
302
|
end
|
304
303
|
|
305
304
|
describe 'create' do
|
306
|
-
it '
|
305
|
+
it 'raises if dump creation fails' do
|
307
306
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('')
|
308
307
|
expect do
|
309
308
|
@cap.find_and_execute_task('dump:remote:create')
|
310
309
|
end.to raise_error('Failed creating dump')
|
311
310
|
end
|
312
311
|
|
313
|
-
it '
|
312
|
+
it 'calls remote rake task with default rails_env and tag remote' do
|
314
313
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
|
315
314
|
grab_output do
|
316
315
|
@cap.find_and_execute_task('dump:remote:create')
|
317
316
|
end
|
318
317
|
end
|
319
318
|
|
320
|
-
it '
|
319
|
+
it 'calls remote rake task with default rails_env and additional tag remote' do
|
321
320
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote,photos").and_return('123.tgz')
|
322
321
|
grab_output do
|
323
|
-
|
322
|
+
Dump::Env.with_env :tags => 'photos' do
|
324
323
|
@cap.find_and_execute_task('dump:remote:create')
|
325
324
|
end
|
326
325
|
end
|
327
326
|
end
|
328
327
|
|
329
|
-
it '
|
328
|
+
it 'calls remote rake task with fetched rails_env and default DESC remote' do
|
330
329
|
expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
|
331
330
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=dev TAGS\\=remote").and_return('123.tgz')
|
332
331
|
grab_output do
|
@@ -341,21 +340,21 @@ describe 'cap dump' do
|
|
341
340
|
:tables => 'rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TABLES\\=some\\ data TAGS\\=remote',
|
342
341
|
}, :return_value => '123.tgz')
|
343
342
|
|
344
|
-
it '
|
343
|
+
it 'prints result of rake task' do
|
345
344
|
allow(@cap.dump).to receive(:run_remote).and_return("123123.tgz\n")
|
346
345
|
expect(grab_output do
|
347
346
|
@cap.find_and_execute_task('dump:remote:create')
|
348
347
|
end[:stdout]).to eq("123123.tgz\n")
|
349
348
|
end
|
350
349
|
|
351
|
-
it '
|
350
|
+
it 'returns stripped result of rake task' do
|
352
351
|
allow(@cap.dump).to receive(:run_remote).and_return("123123.tgz\n")
|
353
352
|
grab_output do
|
354
353
|
expect(@cap.find_and_execute_task('dump:remote:create')).to eq('123123.tgz')
|
355
354
|
end
|
356
355
|
end
|
357
356
|
|
358
|
-
it '
|
357
|
+
it 'uses custom rake binary' do
|
359
358
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
360
359
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:create PROGRESS_TTY\\=\\+ RAILS_ENV\\=production TAGS\\=remote").and_return('123.tgz')
|
361
360
|
grab_output do
|
@@ -365,12 +364,12 @@ describe 'cap dump' do
|
|
365
364
|
end
|
366
365
|
|
367
366
|
describe 'restore' do
|
368
|
-
it '
|
367
|
+
it 'calls remote rake task with default rails_env' do
|
369
368
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
|
370
369
|
@cap.find_and_execute_task('dump:remote:restore')
|
371
370
|
end
|
372
371
|
|
373
|
-
it '
|
372
|
+
it 'calls remote rake task with fetched rails_env' do
|
374
373
|
expect(@cap.dump).to receive(:fetch_rails_env).and_return('dev')
|
375
374
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=dev")
|
376
375
|
@cap.find_and_execute_task('dump:remote:restore')
|
@@ -385,7 +384,7 @@ describe 'cap dump' do
|
|
385
384
|
:restore_assets => 'rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production RESTORE_ASSETS\\=some\\ data',
|
386
385
|
})
|
387
386
|
|
388
|
-
it '
|
387
|
+
it 'uses custom rake binary' do
|
389
388
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
390
389
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:restore PROGRESS_TTY\\=\\+ RAILS_ENV\\=production")
|
391
390
|
@cap.find_and_execute_task('dump:remote:restore')
|
@@ -393,15 +392,15 @@ describe 'cap dump' do
|
|
393
392
|
end
|
394
393
|
|
395
394
|
describe 'download' do
|
396
|
-
it '
|
395
|
+
it 'runs rake versions to get avaliable versions' do
|
397
396
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
398
397
|
@cap.find_and_execute_task('dump:remote:download')
|
399
398
|
end
|
400
399
|
|
401
|
-
it '
|
400
|
+
it 'blocks sending summary to versions' do
|
402
401
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
403
|
-
|
404
|
-
|
402
|
+
Dump::Env::DICTIONARY[:summary].each do |name|
|
403
|
+
Dump::Env.with_env name => 'true' do
|
405
404
|
@cap.find_and_execute_task('dump:remote:download')
|
406
405
|
end
|
407
406
|
end
|
@@ -414,34 +413,34 @@ describe 'cap dump' do
|
|
414
413
|
:transfer_via => 'rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production', # tranfer_via is used internally
|
415
414
|
}, :cap_task => 'dump:remote:download')
|
416
415
|
|
417
|
-
it '
|
416
|
+
it 'does not download anything if there are no versions avaliable' do
|
418
417
|
allow(@cap.dump).to receive(:run_remote).and_return('')
|
419
418
|
expect(@cap.dump).not_to receive(:do_transfer)
|
420
419
|
@cap.find_and_execute_task('dump:remote:download')
|
421
420
|
end
|
422
421
|
|
423
|
-
it '
|
422
|
+
it 'transfers latest version dump' do
|
424
423
|
allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
425
424
|
expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", 'dump/300.tgz')
|
426
425
|
allow(FileUtils).to receive(:mkpath)
|
427
426
|
@cap.find_and_execute_task('dump:remote:download')
|
428
427
|
end
|
429
428
|
|
430
|
-
it '
|
429
|
+
it 'handles extra spaces around file names' do
|
431
430
|
allow(@cap.dump).to receive(:run_remote).and_return("\r\n\r\n\r 100.tgz \r\n\r\n\r 200.tgz \r\n\r\n\r 300.tgz \r\n\r\n\r ")
|
432
431
|
expect(@cap.dump).to receive(:do_transfer).with(:down, "#{@remote_path}/dump/300.tgz", 'dump/300.tgz')
|
433
432
|
allow(FileUtils).to receive(:mkpath)
|
434
433
|
@cap.find_and_execute_task('dump:remote:download')
|
435
434
|
end
|
436
435
|
|
437
|
-
it '
|
436
|
+
it 'creates local dump dir' do
|
438
437
|
allow(@cap.dump).to receive(:run_remote).and_return("100.tgz\n200.tgz\n300.tgz\n")
|
439
438
|
allow(@cap.dump).to receive(:do_transfer)
|
440
439
|
expect(FileUtils).to receive(:mkpath).with('dump')
|
441
440
|
@cap.find_and_execute_task('dump:remote:download')
|
442
441
|
end
|
443
442
|
|
444
|
-
it '
|
443
|
+
it 'runs rake versions use custom rake binary' do
|
445
444
|
expect(@cap.dump).to receive(:fetch_rake).and_return('/custom/rake')
|
446
445
|
expect(@cap.dump).to receive(:run_remote).with("cd #{@remote_path}; /custom/rake -s dump:versions PROGRESS_TTY\\=\\+ RAILS_ENV\\=production").and_return('')
|
447
446
|
@cap.find_and_execute_task('dump:remote:download')
|
@@ -450,14 +449,14 @@ describe 'cap dump' do
|
|
450
449
|
end
|
451
450
|
|
452
451
|
describe 'upload' do
|
453
|
-
it '
|
452
|
+
it 'calls local:upload' do
|
454
453
|
expect(@cap.dump.local).to receive(:upload).and_return('')
|
455
454
|
@cap.find_and_execute_task('dump:upload')
|
456
455
|
end
|
457
456
|
end
|
458
457
|
|
459
458
|
describe 'download' do
|
460
|
-
it '
|
459
|
+
it 'calls remote:download' do
|
461
460
|
expect(@cap.dump.remote).to receive(:download).and_return('')
|
462
461
|
@cap.find_and_execute_task('dump:download')
|
463
462
|
end
|
@@ -468,39 +467,39 @@ describe 'cap dump' do
|
|
468
467
|
src = way[0]
|
469
468
|
dst = way[1]
|
470
469
|
describe name do
|
471
|
-
it '
|
472
|
-
expect(@cap.dump.namespaces[dst]).to receive(:create){ expect(
|
470
|
+
it 'creates auto-backup with tag auto-backup' do
|
471
|
+
expect(@cap.dump.namespaces[dst]).to receive(:create){ expect(Dump::Env[:tags]).to eq('auto-backup'); '' }
|
473
472
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
474
473
|
end
|
475
474
|
|
476
|
-
it '
|
477
|
-
expect(@cap.dump.namespaces[dst]).to receive(:create){ expect(
|
478
|
-
|
475
|
+
it 'creates auto-backup with additional tag auto-backup' do
|
476
|
+
expect(@cap.dump.namespaces[dst]).to receive(:create){ expect(Dump::Env[:tags]).to eq('auto-backup,photos'); '' }
|
477
|
+
Dump::Env.with_env :tags => 'photos' do
|
479
478
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
480
479
|
end
|
481
480
|
end
|
482
481
|
|
483
|
-
it '
|
482
|
+
it 'does not call local:create if auto-backup fails' do
|
484
483
|
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('')
|
485
484
|
expect(@cap.dump.namespaces[src]).not_to receive(:create)
|
486
485
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
487
486
|
end
|
488
487
|
|
489
|
-
it "
|
488
|
+
it "calls local:create if auto-backup succeedes with tags mirror and mirror-#{dir}" do
|
490
489
|
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
491
|
-
expect(@cap.dump.namespaces[src]).to receive(:create){ expect(
|
490
|
+
expect(@cap.dump.namespaces[src]).to receive(:create){ expect(Dump::Env[:tags]).to eq('mirror'); '' }
|
492
491
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
493
492
|
end
|
494
493
|
|
495
|
-
it "
|
494
|
+
it "calls local:create if auto-backup succeedes with additional tags mirror and mirror-#{dir}" do
|
496
495
|
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
497
|
-
expect(@cap.dump.namespaces[src]).to receive(:create){ expect(
|
498
|
-
|
496
|
+
expect(@cap.dump.namespaces[src]).to receive(:create){ expect(Dump::Env[:tags]).to eq('mirror,photos'); '' }
|
497
|
+
Dump::Env.with_env :tags => 'photos' do
|
499
498
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
500
499
|
end
|
501
500
|
end
|
502
501
|
|
503
|
-
it '
|
502
|
+
it 'does not call local:upload or remote:restore if local:create fails' do
|
504
503
|
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
505
504
|
allow(@cap.dump.namespaces[src]).to receive(:create).and_return('')
|
506
505
|
expect(@cap.dump.namespaces[src]).not_to receive(:upload)
|
@@ -508,17 +507,17 @@ describe 'cap dump' do
|
|
508
507
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
509
508
|
end
|
510
509
|
|
511
|
-
it '
|
510
|
+
it 'calls local:upload and remote:restore with only varibale ver set to file name if local:create returns file name' do
|
512
511
|
allow(@cap.dump.namespaces[dst]).to receive(:create).and_return('123.tgz')
|
513
512
|
allow(@cap.dump.namespaces[src]).to receive(:create).and_return('123.tgz')
|
514
513
|
test_env = proc do
|
515
|
-
expect(
|
516
|
-
expect(
|
517
|
-
expect(
|
514
|
+
expect(Dump::Env[:like]).to eq('123.tgz')
|
515
|
+
expect(Dump::Env[:tags]).to eq(nil)
|
516
|
+
expect(Dump::Env[:desc]).to eq(nil)
|
518
517
|
end
|
519
518
|
expect(@cap.dump.namespaces[src]).to receive(:"#{dir}load").ordered(&test_env)
|
520
519
|
expect(@cap.dump.namespaces[dst]).to receive(:restore).ordered(&test_env)
|
521
|
-
|
520
|
+
Dump::Env.with_env all_dictionary_variables do
|
522
521
|
@cap.find_and_execute_task("dump:mirror:#{dir}")
|
523
522
|
end
|
524
523
|
end
|
@@ -527,60 +526,60 @@ describe 'cap dump' do
|
|
527
526
|
end
|
528
527
|
|
529
528
|
describe 'backup' do
|
530
|
-
it '
|
529
|
+
it 'calls remote:create' do
|
531
530
|
expect(@cap.dump.remote).to receive(:create).and_return('')
|
532
531
|
@cap.find_and_execute_task('dump:backup')
|
533
532
|
end
|
534
533
|
|
535
|
-
it '
|
534
|
+
it 'does not call remote:download if remote:create returns blank' do
|
536
535
|
allow(@cap.dump.remote).to receive(:create).and_return('')
|
537
536
|
expect(@cap.dump.remote).not_to receive(:download)
|
538
537
|
@cap.find_and_execute_task('dump:backup')
|
539
538
|
end
|
540
539
|
|
541
|
-
it '
|
540
|
+
it 'calls remote:download if remote:create returns file name' do
|
542
541
|
allow(@cap.dump.remote).to receive(:create).and_return('123.tgz')
|
543
542
|
expect(@cap.dump.remote).to receive(:download).ordered
|
544
543
|
@cap.find_and_execute_task('dump:backup')
|
545
544
|
end
|
546
545
|
|
547
|
-
it '
|
546
|
+
it 'calls remote:create with tag backup' do
|
548
547
|
expect(@cap.dump.remote).to receive(:create) do
|
549
|
-
expect(
|
548
|
+
expect(Dump::Env[:tags]).to eq('backup')
|
550
549
|
''
|
551
550
|
end
|
552
551
|
@cap.find_and_execute_task('dump:backup')
|
553
552
|
end
|
554
553
|
|
555
|
-
it '
|
554
|
+
it 'calls remote:create with additional tag backup' do
|
556
555
|
expect(@cap.dump.remote).to receive(:create) do
|
557
|
-
expect(
|
556
|
+
expect(Dump::Env[:tags]).to eq('backup,photos')
|
558
557
|
''
|
559
558
|
end
|
560
|
-
|
559
|
+
Dump::Env.with_env :tags => 'photos' do
|
561
560
|
@cap.find_and_execute_task('dump:backup')
|
562
561
|
end
|
563
562
|
end
|
564
563
|
|
565
|
-
it '
|
564
|
+
it 'passes description if it is set' do
|
566
565
|
expect(@cap.dump.remote).to receive(:create) do
|
567
|
-
expect(
|
566
|
+
expect(Dump::Env[:desc]).to eq('remote dump')
|
568
567
|
''
|
569
568
|
end
|
570
|
-
|
569
|
+
Dump::Env.with_env :desc => 'remote dump' do
|
571
570
|
@cap.find_and_execute_task('dump:backup')
|
572
571
|
end
|
573
572
|
end
|
574
573
|
|
575
|
-
it '
|
574
|
+
it 'sends only ver variable' do
|
576
575
|
allow(@cap.dump.remote).to receive(:create).and_return('123.tgz')
|
577
576
|
expect(@cap.dump.remote).to receive(:download) do
|
578
|
-
expect(
|
579
|
-
expect(
|
580
|
-
expect(
|
577
|
+
expect(Dump::Env[:like]).to eq('123.tgz')
|
578
|
+
expect(Dump::Env[:tags]).to eq(nil)
|
579
|
+
expect(Dump::Env[:desc]).to eq(nil)
|
581
580
|
''
|
582
581
|
end
|
583
|
-
|
582
|
+
Dump::Env.with_env all_dictionary_variables do
|
584
583
|
@cap.find_and_execute_task('dump:backup')
|
585
584
|
end
|
586
585
|
end
|