Skip to content

Find, verify, and analyze leaked credentials

[INS-331] Fix the issue causing the tests file system soruce tests to fail on windows (#4743)

Muneeb Ullah Khan8df943f8298b
diff --git a/pkg/sources/filesystem/filesystem_test.go b/pkg/sources/filesystem/filesystem_test.go
index 151cada66..07803ca72 100644
--- a/pkg/sources/filesystem/filesystem_test.go
+++ b/pkg/sources/filesystem/filesystem_test.go
@@ -347,7 +347,8 @@ func TestSkipDir(t *testing.T) {
defer cleanupDir()
// create an ExcludePathsFile that contains the ignoreDir path
- excludeFile, cleanupFile, err := createTempFile("", ignoreDir+"\n")
+ // In windows path contains \ so we escape it by replacing it with \\ in ignoreDir
+ excludeFile, cleanupFile, err := createTempFile("", strings.ReplaceAll(ignoreDir, `\`, `\\`)+"\n")
require.NoError(t, err)
defer cleanupFile()
@@ -392,8 +393,8 @@ func TestScanSubDirFile(t *testing.T) {
// Create an IncludePathsFile with the absolute path of the file
includeFilePath := filepath.Join(testDir, "include.txt")
- err = os.WriteFile(includeFilePath, []byte(filePath+"\n"), 0644)
- require.NoError(t, err)
+ err = os.WriteFile(includeFilePath, []byte(strings.ReplaceAll(filePath, `\`, `\\`)+"\n"), 0644)
+ require.NoError(t, err)
conn, err := anypb.New(&sourcespb.Filesystem{
IncludePathsFile: includeFilePath,