5
5
"io/ioutil"
6
6
"os"
7
7
"path/filepath"
8
+ "runtime"
8
9
"testing"
9
10
)
10
11
@@ -29,6 +30,10 @@ func TestWriteFile(t *testing.T) {
29
30
})
30
31
31
32
t .Run ("write file with directory permission error" , func (t * testing.T ) {
33
+ if runtime .GOOS == "windows" {
34
+ t .Skip ("skipping test on Windows" )
35
+ }
36
+
32
37
tempDir := t .TempDir ()
33
38
data := []byte ("data" )
34
39
// forbid writing to tempDir
@@ -80,6 +85,10 @@ func TestWriteFileWithPermission(t *testing.T) {
80
85
})
81
86
82
87
t .Run ("write with directory permission error" , func (t * testing.T ) {
88
+ if runtime .GOOS == "windows" {
89
+ t .Skip ("skipping test on Windows" )
90
+ }
91
+
83
92
tempDir := t .TempDir ()
84
93
data := []byte ("data" )
85
94
filename := filepath .Join (tempDir , "a" , "file.txt" )
@@ -124,6 +133,10 @@ func TestCopyToDir(t *testing.T) {
124
133
})
125
134
126
135
t .Run ("source directory permission error" , func (t * testing.T ) {
136
+ if runtime .GOOS == "windows" {
137
+ t .Skip ("skipping test on Windows" )
138
+ }
139
+
127
140
tempDir := t .TempDir ()
128
141
destDir := t .TempDir ()
129
142
data := []byte ("data" )
@@ -151,6 +164,10 @@ func TestCopyToDir(t *testing.T) {
151
164
})
152
165
153
166
t .Run ("source file permission error" , func (t * testing.T ) {
167
+ if runtime .GOOS == "windows" {
168
+ t .Skip ("skipping test on Windows" )
169
+ }
170
+
154
171
tempDir := t .TempDir ()
155
172
destDir := t .TempDir ()
156
173
data := []byte ("data" )
@@ -170,6 +187,10 @@ func TestCopyToDir(t *testing.T) {
170
187
})
171
188
172
189
t .Run ("dest directory permission error" , func (t * testing.T ) {
190
+ if runtime .GOOS == "windows" {
191
+ t .Skip ("skipping test on Windows" )
192
+ }
193
+
173
194
tempDir := t .TempDir ()
174
195
destTempDir := t .TempDir ()
175
196
data := []byte ("data" )
@@ -189,6 +210,10 @@ func TestCopyToDir(t *testing.T) {
189
210
})
190
211
191
212
t .Run ("dest directory permission error 2" , func (t * testing.T ) {
213
+ if runtime .GOOS == "windows" {
214
+ t .Skip ("skipping test on Windows" )
215
+ }
216
+
192
217
tempDir := t .TempDir ()
193
218
destTempDir := t .TempDir ()
194
219
data := []byte ("data" )
@@ -197,7 +222,7 @@ func TestCopyToDir(t *testing.T) {
197
222
if err := WriteFile (filename , data ); err != nil {
198
223
t .Fatal (err )
199
224
}
200
- // forbid dest directory operation
225
+ // forbid writing to destTempDir
201
226
if err := os .Chmod (destTempDir , 0000 ); err != nil {
202
227
t .Fatal (err )
203
228
}
@@ -207,7 +232,7 @@ func TestCopyToDir(t *testing.T) {
207
232
}
208
233
})
209
234
210
- t .Run ("valid file content" , func (t * testing.T ) {
235
+ t .Run ("copy file and check content" , func (t * testing.T ) {
211
236
tempDir := t .TempDir ()
212
237
data := []byte ("data" )
213
238
filename := filepath .Join (tempDir , "a" , "file.txt" )
0 commit comments