@@ -255,6 +255,93 @@ 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 "generate a copy command instead of a mkdir command for 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
+
291
+ @instruction_builder
292
+ . expects ( :mkdir )
293
+ . with ( "dst1/src1" )
294
+ . never
295
+ @instruction_builder
296
+ . expects ( :copy )
297
+ . with ( "deploy-archive-dir/src1" , "dst1/src1" )
298
+ . in_sequence ( @command_sequence )
299
+
300
+ @installer . install ( @deployment_group_id , @app_spec )
301
+ end
302
+
303
+ should "generate a copy command if the file inside the source directory is a symbolic link of a regular file" do
304
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1" ) . returns ( true )
305
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1" ) . returns ( false )
306
+ Dir . stubs ( :entries )
307
+ . with ( "deploy-archive-dir/src1" )
308
+ . returns ( [ "." , ".." , "foo" ] )
309
+
310
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( false )
311
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( true )
312
+
313
+ @instruction_builder
314
+ . expects ( :copy )
315
+ . with ( "deploy-archive-dir/src1/foo" , "dst1/foo" )
316
+ . in_sequence ( @command_sequence )
317
+
318
+ @installer . install ( @deployment_group_id , @app_spec )
319
+ end
320
+
321
+ 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
322
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1" ) . returns ( true )
323
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1" ) . returns ( false )
324
+ Dir . stubs ( :entries )
325
+ . with ( "deploy-archive-dir/src1" )
326
+ . returns ( [ "." , ".." , "foo" ] )
327
+
328
+ File . stubs ( :directory? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( true )
329
+ File . stubs ( :symlink? ) . with ( "deploy-archive-dir/src1/foo" ) . returns ( true )
330
+
331
+ @instruction_builder
332
+ . expects ( :mkdir )
333
+ . with ( "dst1/foo" )
334
+ . never
335
+ @instruction_builder
336
+ . expects ( :copy )
337
+ . with ( "deploy-archive-dir/src1/foo" , "dst1/foo" )
338
+ . in_sequence ( @command_sequence )
339
+
340
+ @installer . install ( @deployment_group_id , @app_spec )
341
+ end
342
+
343
+ end # "symlinks"
344
+
258
345
context "directories" do
259
346
260
347
setup do
0 commit comments