@@ -447,6 +447,29 @@ func (s *FilesystemSuite) TestReadDirFileInfoDirs(c *C) {
447
447
c .Assert (info [0 ].Mode (), Not (Equals ), 0 )
448
448
}
449
449
450
+ func (s * FilesystemSuite ) TestStat (c * C ) {
451
+ WriteFile (s .FS , "foo/bar" , []byte ("foo" ), customMode )
452
+
453
+ fi , err := s .FS .Stat ("foo/bar" )
454
+ c .Assert (err , IsNil )
455
+ c .Assert (fi .Name (), Equals , "bar" )
456
+ c .Assert (fi .Size (), Equals , int64 (3 ))
457
+ c .Assert (fi .Mode (), Equals , customMode )
458
+ c .Assert (fi .ModTime ().IsZero (), Equals , false )
459
+ c .Assert (fi .IsDir (), Equals , false )
460
+ }
461
+
462
+ func (s * FilesystemSuite ) TestStatDir (c * C ) {
463
+ s .FS .MkdirAll ("foo/bar" , 0644 )
464
+
465
+ fi , err := s .FS .Stat ("foo/bar" )
466
+ c .Assert (err , IsNil )
467
+ c .Assert (fi .Name (), Equals , "bar" )
468
+ c .Assert (fi .Mode ().IsDir (), Equals , true )
469
+ c .Assert (fi .ModTime ().IsZero (), Equals , false )
470
+ c .Assert (fi .IsDir (), Equals , true )
471
+ }
472
+
450
473
func (s * FilesystemSuite ) TestStatNonExistent (c * C ) {
451
474
fi , err := s .FS .Stat ("non-existent" )
452
475
comment := Commentf ("error: %s" , err )
@@ -512,6 +535,26 @@ func (s *FilesystemSuite) TestRename(c *C) {
512
535
c .Assert (err , IsNil )
513
536
}
514
537
538
+ func (s * FilesystemSuite ) TestRenameToDir (c * C ) {
539
+ err := WriteFile (s .FS , "foo" , nil , 0644 )
540
+ c .Assert (err , IsNil )
541
+
542
+ err = s .FS .Rename ("foo" , "bar/qux" )
543
+ c .Assert (err , IsNil )
544
+
545
+ old , err := s .FS .Stat ("foo" )
546
+ c .Assert (old , IsNil )
547
+ c .Assert (os .IsNotExist (err ), Equals , true )
548
+
549
+ dir , err := s .FS .Stat ("bar" )
550
+ c .Assert (dir , NotNil )
551
+ c .Assert (err , IsNil )
552
+
553
+ file , err := s .FS .Stat ("bar/qux" )
554
+ c .Assert (file .Name (), Equals , "qux" )
555
+ c .Assert (err , IsNil )
556
+ }
557
+
515
558
func (s * FilesystemSuite ) TestRenameDir (c * C ) {
516
559
err := s .FS .MkdirAll ("foo" , 0644 )
517
560
c .Assert (err , IsNil )
0 commit comments