@@ -255,6 +255,104 @@ class CodeDeployPluginInstallerTest < InstanceAgentTestCase
255
255
256
256
end # "regular files"
257
257
258
+ context "symbolic links" do
259
+
260
+ setup do
261
+ @app_spec
262
+ . stubs ( :files )
263
+ . returns ( [ stub ( :source => "src1" ,
264
+ :destination => "dst1" ) ] )
265
+
266
+ File . stubs ( :directory? ) . returns ( false )
267
+ File . stubs ( :directory? ) . with ( "dst1" ) . returns ( true )
268
+
269
+ File . stubs ( :exists? ) . returns ( false )
270
+ File . stubs ( :exists? ) . with ( "dst1" ) . returns ( true )
271
+
272
+ @command_sequence = sequence ( "commands" )
273
+ end
274
+
275
+ should "generate a copy command for the source file if it is a symbolic link of a regular file" do
276
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1" ) . returns ( false )
277
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1" ) . returns ( true )
278
+
279
+ @instruction_builder
280
+ . expects ( :copy )
281
+ . with ( "deploy-archive-dir/src1" , "dst1/src1" )
282
+ . in_sequence ( @command_sequence )
283
+
284
+ @installer . install ( @deployment_group_id , @app_spec )
285
+ end
286
+
287
+ should "not generate a copy command for the entries of the source file if it is a symbolic link of a directory" do
288
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1" ) . returns ( true )
289
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1" ) . returns ( true )
290
+ Dir . stubs ( :entries )
291
+ . with ( "deploy-archive-dir/src1" )
292
+ . returns ( [ "." , ".." , "foo" ] )
293
+
294
+ @instruction_builder
295
+ . expects ( :copy )
296
+ . with ( "deploy-archive-dir/src1" , "dst1/src1" )
297
+ . in_sequence ( @command_sequence )
298
+ @instruction_builder
299
+ . expects ( :copy )
300
+ . with ( "deploy-archive-dir/src1/foo" , "dst1/foo" )
301
+ . never
302
+
303
+ @installer . install ( @deployment_group_id , @app_spec )
304
+ end
305
+
306
+ should "generate a copy command if the file inside the source directory is a symbolic link of a regular file" do
307
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1" ) . returns ( true )
308
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1" ) . returns ( false )
309
+ Dir . stubs ( :entries )
310
+ . with ( "deploy-archive-dir/src1" )
311
+ . returns ( [ "." , ".." , "foo" ] )
312
+
313
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( false )
314
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( true )
315
+
316
+ @instruction_builder
317
+ . expects ( :copy )
318
+ . with ( "deploy-archive-dir/src1/foo" , "dst1/foo" )
319
+ . in_sequence ( @command_sequence )
320
+
321
+ @installer . install ( @deployment_group_id , @app_spec )
322
+ end
323
+
324
+ should "generate a copy command instead of a mkdir command if the file inside the source directory is a symbolic link of a directory" do
325
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1" ) . returns ( true )
326
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1" ) . returns ( false )
327
+ Dir . stubs ( :entries )
328
+ . with ( "deploy-archive-dir/src1" )
329
+ . returns ( [ "." , ".." , "foo" ] )
330
+
331
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( true )
332
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( true )
333
+ Dir . stubs ( :entries )
334
+ . with ( "deploy-archive-dir/src1/foo" )
335
+ . returns ( [ "." , ".." , "bar" ] )
336
+
337
+
338
+ @instruction_builder
339
+ . expects ( :mkdir )
340
+ . with ( "dst1/foo" )
341
+ . never
342
+ @instruction_builder
343
+ . expects ( :copy )
344
+ . with ( "deploy-archive-dir/src1/foo" , "dst1/foo" )
345
+ . in_sequence ( @command_sequence )
346
+ @instruction_builder
347
+ . expects ( :copy )
348
+ . with ( "deploy-archive-dir/src1/foo/bar" , "dst1/foo/bar" )
349
+ . never
350
+
351
+ @installer . install ( @deployment_group_id , @app_spec )
352
+ end
353
+
354
+ end # "symlinks"
355
+
258
356
context "directories" do
259
357
260
358
setup do
0 commit comments