File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1286,6 +1286,39 @@ func TestFindFiles_InNonexistentPathReturnsError(t *testing.T) {
1286
1286
}
1287
1287
}
1288
1288
1289
+ func TestFindFiles_DoesNotErrorWhenSubDirectoryIsNotReadable (t * testing.T ) {
1290
+ t .Parallel ()
1291
+ tmpDir := t .TempDir ()
1292
+ fileAPath := filepath .Join (tmpDir , "file_a.txt" )
1293
+ if err := os .WriteFile (fileAPath , []byte ("hello world!" ), os .ModePerm ); err != nil {
1294
+ t .Fatal (err )
1295
+ }
1296
+ restrictedDirPath := filepath .Join (tmpDir , "restricted_dir" )
1297
+ if err := os .Mkdir (restrictedDirPath , os .ModePerm ); err != nil {
1298
+ t .Fatal (err )
1299
+ }
1300
+ fileBPath := filepath .Join (restrictedDirPath , "file_b.txt" )
1301
+ if err := os .WriteFile (fileBPath , []byte ("hello again!" ), os .ModePerm ); err != nil {
1302
+ t .Fatal (err )
1303
+ }
1304
+ if err := os .Chmod (restrictedDirPath , 0o000 ); err != nil {
1305
+ t .Fatal (err )
1306
+ }
1307
+ t .Cleanup (func () { os .Chmod (restrictedDirPath , os .ModePerm ) })
1308
+ p := script .FindFiles (tmpDir )
1309
+ if p .Error () != nil {
1310
+ t .Fatal (p .Error ())
1311
+ }
1312
+ want := fileAPath + "\n "
1313
+ got , err := p .String ()
1314
+ if err != nil {
1315
+ t .Fatal (err )
1316
+ }
1317
+ if ! cmp .Equal (want , got ) {
1318
+ t .Fatal (cmp .Diff (want , got ))
1319
+ }
1320
+ }
1321
+
1289
1322
func TestIfExists_ProducesErrorPlusNoOutputForNonexistentFile (t * testing.T ) {
1290
1323
t .Parallel ()
1291
1324
want := ""
You can’t perform that action at this time.
0 commit comments