@@ -17,10 +17,12 @@ limitations under the License.
17
17
package util
18
18
19
19
import (
20
+ "io/ioutil"
21
+ "os"
22
+ "path/filepath"
20
23
"testing"
21
24
22
25
"github.com/GoogleContainerTools/skaffold/testutil"
23
- "github.com/spf13/afero"
24
26
)
25
27
26
28
func TestSupportedKubernetesFormats (t * testing.T ) {
@@ -62,13 +64,13 @@ func TestSupportedKubernetesFormats(t *testing.T) {
62
64
}
63
65
64
66
func TestExpandPathsGlob (t * testing.T ) {
65
- defer func ( fs afero. Fs ) { Fs = fs }( Fs )
66
- Fs = afero . NewMemMapFs ()
67
+ tmp , cleanup := testutil . TempDir ( t )
68
+ defer cleanup ()
67
69
68
- Fs .MkdirAll ("dir/ sub_dir" , 0700 )
69
- Fs .MkdirAll ("dir_b/ sub_dir_b" , 0700 )
70
- afero .WriteFile (Fs , "dir_b/ sub_dir_b/ file" , []byte ("" ), 0650 )
71
- afero .WriteFile (Fs , "dir/ sub_dir/ file" , []byte ("" ), 0650 )
70
+ os .MkdirAll (filepath . Join ( tmp , "dir" , " sub_dir") , 0700 )
71
+ os .MkdirAll (filepath . Join ( tmp , "dir_b" , " sub_dir_b") , 0700 )
72
+ ioutil .WriteFile (filepath . Join ( tmp , "dir_b" , " sub_dir_b" , " file") , []byte ("" ), 0650 )
73
+ ioutil .WriteFile (filepath . Join ( tmp , "dir" , " sub_dir" , " file") , []byte ("" ), 0650 )
72
74
73
75
var tests = []struct {
74
76
description string
@@ -79,17 +81,17 @@ func TestExpandPathsGlob(t *testing.T) {
79
81
{
80
82
description : "match exact filename" ,
81
83
in : []string {"dir/sub_dir/file" },
82
- out : []string {"dir/ sub_dir/ file" },
84
+ out : []string {filepath . Join ( tmp , "dir" , " sub_dir" , " file") },
83
85
},
84
86
{
85
87
description : "match leaf directory glob" ,
86
88
in : []string {"dir/sub_dir/*" },
87
- out : []string {"dir/ sub_dir/ file" },
89
+ out : []string {filepath . Join ( tmp , "dir" , " sub_dir" , " file") },
88
90
},
89
91
{
90
92
description : "match top level glob" ,
91
93
in : []string {"dir*" },
92
- out : []string {"dir/ sub_dir/ file" , "dir_b/ sub_dir_b/ file" },
94
+ out : []string {filepath . Join ( tmp , "dir" , " sub_dir" , " file"), filepath . Join ( tmp , "dir_b" , " sub_dir_b" , " file") },
93
95
},
94
96
{
95
97
description : "error unmatched glob" ,
@@ -100,7 +102,8 @@ func TestExpandPathsGlob(t *testing.T) {
100
102
101
103
for _ , tt := range tests {
102
104
t .Run (tt .description , func (t * testing.T ) {
103
- actual , err := ExpandPathsGlob (tt .in )
105
+ actual , err := ExpandPathsGlob (tmp , tt .in )
106
+
104
107
testutil .CheckErrorAndDeepEqual (t , tt .shouldErr , err , tt .out , actual )
105
108
})
106
109
}
0 commit comments