@@ -11,44 +11,6 @@ import (
1111 "github.com/stretchr/testify/suite"
1212)
1313
14- // ***********************
15- // * FILESYSTEM FIXTURES *
16- // ***********************
17- // The following functions provide different "scenarios"
18- // that you might encounter in a filesystem tree.
19-
20- func HelloWorld (root * Path ) error {
21- hello := root .Join ("hello.txt" )
22- return hello .WriteFile ([]byte ("hello world" ), 0o644 )
23- }
24-
25- func OneFile (root * Path , name string , content string ) error {
26- file := root .Join (name )
27- return file .WriteFile ([]byte (content ), 0o644 )
28- }
29-
30- func NFiles (root * Path , n int ) error {
31- for i := 0 ; i < n ; i ++ {
32- if err := OneFile (root , fmt .Sprintf ("file%d.txt" , i ), fmt .Sprintf ("file%d contents" , i )); err != nil {
33- return err
34- }
35- }
36- return nil
37- }
38-
39- // TwoFilesAtRootTwoInSubdir creates two files in the root dir,
40- // a directory, and creates two files inside that new directory.
41- func TwoFilesAtRootTwoInSubdir (root * Path ) error {
42- if err := NFiles (root , 2 ); err != nil {
43- return err
44- }
45- subdir := root .Join ("subdir" )
46- if err := subdir .Mkdir (0o777 ); err != nil {
47- return err
48- }
49- return NFiles (subdir , 2 )
50- }
51-
5214// *********
5315// * TESTS *
5416// *********
@@ -60,7 +22,7 @@ type WalkSuiteAll struct {
6022 suite.Suite
6123 walk * Walk
6224 root * Path
63- algorithm string
25+ algorithm Algorithm
6426 Fs afero.Fs
6527}
6628
@@ -71,7 +33,7 @@ func (w *WalkSuiteAll) SetupTest() {
7133 w .root = NewPathAfero ("/" , w .Fs )
7234 w .walk , err = NewWalk (w .root )
7335 require .NoError (w .T (), err )
74- w .walk .Opts .WalkAlgorithm = w .algorithm
36+ w .walk .Opts .Algorithm = w .algorithm
7537}
7638
7739func (w * WalkSuiteAll ) TeardownTest () {
@@ -144,9 +106,9 @@ func (w *WalkSuiteAll) TestWalkFuncErr() {
144106}
145107
146108func TestWalkSuite (t * testing.T ) {
147- for _ , algorithm := range []string {
148- AlgorithmBasic () ,
149- AlgorithmDepthFirst () ,
109+ for _ , algorithm := range []Algorithm {
110+ AlgorithmBasic ,
111+ AlgorithmDepthFirst ,
150112 } {
151113 walkSuite := new (WalkSuiteAll )
152114 walkSuite .algorithm = algorithm
@@ -159,7 +121,7 @@ func TestDefaultWalkOpts(t *testing.T) {
159121 name string
160122 want * WalkOpts
161123 }{
162- {"assert defaults" , & WalkOpts {- 1 , AlgorithmBasic () , false , 100 }},
124+ {"assert defaults" , & WalkOpts {- 1 , AlgorithmBasic , false }},
163125 }
164126 for _ , tt := range tests {
165127 t .Run (tt .name , func (t * testing.T ) {
@@ -170,6 +132,8 @@ func TestDefaultWalkOpts(t *testing.T) {
170132 }
171133}
172134
135+ var ConfusedWandering Algorithm = 0xBADC0DE
136+
173137func TestWalk_Walk (t * testing.T ) {
174138 type fields struct {
175139 Opts * WalkOpts
@@ -187,7 +151,7 @@ func TestWalk_Walk(t *testing.T) {
187151 {
188152 name : "Bad algoritm" ,
189153 fields : fields {
190- Opts : & WalkOpts {WalkAlgorithm : "confused wandering" },
154+ Opts : & WalkOpts {Algorithm : ConfusedWandering },
191155 },
192156 wantErr : true ,
193157 },
0 commit comments