@@ -0,0 +1,44 @@
1+package fsext
2+
3+import (
4+ "os"
5+ "testing"
6+
7+ "github.com/stretchr/testify/require"
8+)
9+
10+func TestCrushIgnore(t *testing.T) {
11+ // Create a temporary directory for testing
12+ tempDir := t.TempDir()
13+
14+ // Change to temp directory
15+ oldWd, _ := os.Getwd()
16+ err := os.Chdir(tempDir)
17+ require.NoError(t, err)
18+ defer os.Chdir(oldWd)
19+
20+ // Create test files
21+ require.NoError(t, os.WriteFile("test1.txt", []byte("test"), 0644))
22+ require.NoError(t, os.WriteFile("test2.log", []byte("test"), 0644))
23+ require.NoError(t, os.WriteFile("test3.tmp", []byte("test"), 0644))
24+
25+ // Create a .crushignore file that ignores .log files
26+ require.NoError(t, os.WriteFile(".crushignore", []byte("*.log\n"), 0644))
27+
28+ // Test DirectoryLister
29+ t.Run("DirectoryLister respects .crushignore", func(t *testing.T) {
30+ dl := NewDirectoryLister(tempDir)
31+
32+ // Test that .log files are ignored
33+ require.True(t, dl.gitignore == nil, "gitignore should be nil")
34+ require.NotNil(t, dl.crushignore, "crushignore should not be nil")
35+ })
36+
37+ // Test FastGlobWalker
38+ t.Run("FastGlobWalker respects .crushignore", func(t *testing.T) {
39+ walker := NewFastGlobWalker(tempDir)
40+
41+ require.True(t, walker.gitignore == nil, "gitignore should be nil")
42+ require.NotNil(t, walker.crushignore, "crushignore should not be nil")
43+ })
44+}