Skip to content

Commit

Permalink
test for subitem
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Apr 14, 2024
1 parent fdf8d61 commit bece451
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/remove/parallel_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/dundee/gdu/v5/internal/testdir"
"github.com/dundee/gdu/v5/pkg/analyze"
"github.com/dundee/gdu/v5/pkg/fs"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -40,3 +41,27 @@ func TestRemoveItemFromDirParallelWithErr(t *testing.T) {
err = RemoveItemFromDirParallel(dir, subdir)
assert.Contains(t, err.Error(), "permission denied")
}

func TestRemoveItemFromDirParallelWithErr2(t *testing.T) {
fin := testdir.CreateTestDir()
defer fin()

err := os.Chmod("test_dir/nested/subnested", 0)
assert.Nil(t, err)
defer func() {
err = os.Chmod("test_dir/nested/subnested", 0755)
assert.Nil(t, err)
}()

analyzer := analyze.CreateAnalyzer()
dir := analyzer.AnalyzeDir(
"test_dir", func(_, _ string) bool { return false }, false,
).(*analyze.Dir)
analyzer.GetDone().Wait()
dir.UpdateStats(make(fs.HardLinkedItems))

subdir := dir.Files[0].(*analyze.Dir)

err = RemoveItemFromDirParallel(dir, subdir)
assert.Contains(t, err.Error(), "permission denied")
}

0 comments on commit bece451

Please sign in to comment.