@@ -20,6 +20,7 @@ type WalkSuite struct{}
2020func TestWalk (t * testing.T ) { TestingT (t ) }
2121
2222var _ = Suite (& WalkSuite {})
23+ var targetSubfolder = filepath .FromSlash ("path/to/some/subfolder" )
2324
2425func (s * WalkSuite ) TestWalkCanSkipTopDirectory (c * C ) {
2526 filesystem := memfs .New ()
@@ -52,13 +53,13 @@ func (s *WalkSuite) TestWalkOnExistingFolder(c *C) {
5253 return nil
5354 }), IsNil )
5455 c .Assert (discoveredPaths , Contains , "path" )
55- c .Assert (discoveredPaths , Contains , "path/to" )
56- c .Assert (discoveredPaths , Contains , "path/to/some" )
57- c .Assert (discoveredPaths , Contains , "path/to/some/file" )
58- c .Assert (discoveredPaths , Contains , "path/to/some/subfolder" )
59- c .Assert (discoveredPaths , Contains , "path/to/some/subfolder/that" )
60- c .Assert (discoveredPaths , Contains , "path/to/some/subfolder/that/contain" )
61- c .Assert (discoveredPaths , Contains , "path/to/some/subfolder/that/contain/file" )
56+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to" ) )
57+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some" ) )
58+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/file" ) )
59+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/subfolder" ) )
60+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/subfolder/that" ) )
61+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/subfolder/that/contain" ) )
62+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/subfolder/that/contain/file" ) )
6263}
6364
6465func (s * WalkSuite ) TestWalkCanSkipFolder (c * C ) {
@@ -68,19 +69,19 @@ func (s *WalkSuite) TestWalkCanSkipFolder(c *C) {
6869 discoveredPaths := []string {}
6970 c .Assert (util .Walk (filesystem , "path" , func (path string , info os.FileInfo , err error ) error {
7071 discoveredPaths = append (discoveredPaths , path )
71- if path == "path/to/some/subfolder" {
72+ if path == targetSubfolder {
7273 return filepath .SkipDir
7374 }
7475 return nil
7576 }), IsNil )
7677 c .Assert (discoveredPaths , Contains , "path" )
77- c .Assert (discoveredPaths , Contains , "path/to" )
78- c .Assert (discoveredPaths , Contains , "path/to/some" )
79- c .Assert (discoveredPaths , Contains , "path/to/some/file" )
80- c .Assert (discoveredPaths , Contains , "path/to/some/subfolder" )
81- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that" )
82- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that/contain" )
83- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that/contain/file" )
78+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to" ) )
79+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some" ) )
80+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/file" ) )
81+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/subfolder" ) )
82+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that" ) )
83+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that/contain" ) )
84+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that/contain/file" ) )
8485}
8586
8687func (s * WalkSuite ) TestWalkStopsOnError (c * C ) {
@@ -90,27 +91,27 @@ func (s *WalkSuite) TestWalkStopsOnError(c *C) {
9091 discoveredPaths := []string {}
9192 c .Assert (util .Walk (filesystem , "path" , func (path string , info os.FileInfo , err error ) error {
9293 discoveredPaths = append (discoveredPaths , path )
93- if path == "path/to/some/subfolder" {
94+ if path == targetSubfolder {
9495 return errors .New ("uncaught error" )
9596 }
9697 return nil
9798 }), NotNil )
9899 c .Assert (discoveredPaths , Contains , "path" )
99- c .Assert (discoveredPaths , Contains , "path/to" )
100- c .Assert (discoveredPaths , Contains , "path/to/some" )
101- c .Assert (discoveredPaths , Contains , "path/to/some/file" )
102- c .Assert (discoveredPaths , Contains , "path/to/some/subfolder" )
103- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that" )
104- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that/contain" )
105- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that/contain/file" )
100+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to" ) )
101+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some" ) )
102+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/file" ) )
103+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/subfolder" ) )
104+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that" ) )
105+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that/contain" ) )
106+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that/contain/file" ) )
106107}
107108
108109func (s * WalkSuite ) TestWalkForwardsStatErrors (c * C ) {
109110 memFilesystem := memfs .New ()
110111 filesystem := & fnFs {
111112 Filesystem : memFilesystem ,
112113 lstat : func (path string ) (os.FileInfo , error ) {
113- if path == "path/to/some/subfolder" {
114+ if path == targetSubfolder {
114115 return nil , errors .New ("uncaught error" )
115116 }
116117 return memFilesystem .Lstat (path )
@@ -122,19 +123,19 @@ func (s *WalkSuite) TestWalkForwardsStatErrors(c *C) {
122123 discoveredPaths := []string {}
123124 c .Assert (util .Walk (filesystem , "path" , func (path string , info os.FileInfo , err error ) error {
124125 discoveredPaths = append (discoveredPaths , path )
125- if path == "path/to/some/subfolder" {
126+ if path == targetSubfolder {
126127 c .Assert (err , NotNil )
127128 }
128129 return err
129130 }), NotNil )
130131 c .Assert (discoveredPaths , Contains , "path" )
131- c .Assert (discoveredPaths , Contains , "path/to" )
132- c .Assert (discoveredPaths , Contains , "path/to/some" )
133- c .Assert (discoveredPaths , Contains , "path/to/some/file" )
134- c .Assert (discoveredPaths , Contains , "path/to/some/subfolder" )
135- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that" )
136- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that/contain" )
137- c .Assert (discoveredPaths , NotContain , "path/to/some/subfolder/that/contain/file" )
132+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to" ) )
133+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some" ) )
134+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/file" ) )
135+ c .Assert (discoveredPaths , Contains , filepath . FromSlash ( "path/to/some/subfolder" ) )
136+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that" ) )
137+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that/contain" ) )
138+ c .Assert (discoveredPaths , NotContain , filepath . FromSlash ( "path/to/some/subfolder/that/contain/file" ) )
138139}
139140
140141func createFile (c * C , filesystem billy.Filesystem , path string ) {
0 commit comments