@@ -27,6 +27,24 @@ func TestCopy(t *testing.T) {
2727 assertFile (t , filepath .Join (tmp , "a/ab/ab2.txt" ))
2828 })
2929
30+ t .Run ("recursively copy directory into populated dest dir" , func (t * testing.T ) {
31+ tmp , err := ioutil .TempDir ("" , "magex" )
32+ require .NoError (t , err , "could not create temp directory for test" )
33+ defer os .RemoveAll (tmp )
34+
35+ require .NoError (t , os .MkdirAll (filepath .Join (tmp , "a" ), 0755 ))
36+
37+ err = Copy ("testdata/copy/a" , tmp , CopyRecursive )
38+ require .NoError (t , err , "Copy into directory with same directory name" )
39+
40+ assert .DirExists (t , filepath .Join (tmp , "a" ))
41+ assertFile (t , filepath .Join (tmp , "a/a1.txt" ))
42+ assertFile (t , filepath .Join (tmp , "a/a2.txt" ))
43+ assert .DirExists (t , filepath .Join (tmp , "a/ab" ))
44+ assertFile (t , filepath .Join (tmp , "a/ab/ab1.txt" ))
45+ assertFile (t , filepath .Join (tmp , "a/ab/ab2.txt" ))
46+ })
47+
3048 t .Run ("copy glob" , func (t * testing.T ) {
3149 tmp , err := ioutil .TempDir ("" , "magex" )
3250 require .NoError (t , err , "could not create temp directory for test" )
0 commit comments