Skip to content

Commit

Permalink
Skip TestFastWalk_ErrPermission as root user
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshpatra committed Oct 26, 2024
1 parent 17800a2 commit 9237506
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fastwalk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io/fs"
"math"
"os"
"os/user"
"path/filepath"
"reflect"
"regexp"
Expand Down Expand Up @@ -87,6 +88,15 @@ func cleanupOrLogTempDir(t *testing.T, tempdir string) {
}
}

func checkRoot() bool {
test_user, err := user.Current()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
return test_user.Username == "root"
}

func testCreateFiles(t *testing.T, tempdir string, files map[string]string) {
symlinks := map[string]string{}
for path, contents := range files {
Expand Down Expand Up @@ -981,6 +991,9 @@ func TestFastWalk_ErrNotExist(t *testing.T) {
}

func TestFastWalk_ErrPermission(t *testing.T) {
if checkRoot() {
t.Skip("Skip test as root user")
}
if runtime.GOOS == "windows" {
t.Skip("test not supported for Windows")
}
Expand Down

0 comments on commit 9237506

Please sign in to comment.