Skip to content

Commit ac98874

Browse files
Add integration test to check for . and ..
1 parent 3c8ed18 commit ac98874

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/e2e_tests/dir_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,35 @@ func (suite *dirTestSuite) TestDirList() {
463463
suite.dirTestCleanup([]string{testDir})
464464
}
465465

466+
// # List directory with dot entries
467+
func (suite *dirTestSuite) TestDirListShowsDots() {
468+
if runtime.GOOS == "windows" {
469+
fmt.Println("Skipping TestDirListShowsDots on Windows")
470+
return
471+
}
472+
cmd := exec.Command("ls", "-al", suite.testPath)
473+
cliOut, err := cmd.Output()
474+
suite.NoError(err)
475+
lines := strings.Split(string(cliOut), "\n")
476+
foundDot := false
477+
foundDotDot := false
478+
for _, line := range lines {
479+
fields := strings.Fields(line)
480+
if len(fields) == 0 {
481+
continue
482+
}
483+
name := fields[len(fields)-1]
484+
switch name {
485+
case ".":
486+
foundDot = true
487+
case "..":
488+
foundDotDot = true
489+
}
490+
}
491+
suite.True(foundDot, "expected '.' to be listed in ls -al output")
492+
suite.True(foundDotDot, "expected '..' to be listed in ls -al output")
493+
}
494+
466495
// // # List directory recursively
467496
// func (suite *dirTestSuite) TestDirListRecursive() {
468497
// testDir := filepath.Join(suite.testPath, "bigTestDir")

0 commit comments

Comments
 (0)