Skip to content

Commit 8386601

Browse files
committed
try fix tests
1 parent 89fdf98 commit 8386601

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tests/utils/test_utils.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,14 @@ func CreateTestWatch(t *testing.T, policyName string, watchName, severity xrayUt
326326
}
327327

328328
func CreateTestProjectInTempDir(t *testing.T, projectPath string) (string, func()) {
329-
// TODO: We are not using coreTests.CreateTempDirWithCallbackAndAssert(t) since the callback fails to remove the temp dir on Windows.
330-
// (Unknown reason, should be investigated)
331-
// tempDirPath := t.TempDir()
332-
tempDirPath, clean := coreTests.CreateTempDirWithCallbackAndAssert(t)
333-
// maskedPath := filepath.Join(tempDirPath, filepath.Base(projectPath))
334-
assert.NoError(t, biutils.CopyDir(projectPath, tempDirPath, true, nil))
335-
return tempDirPath, clean
329+
tempDirPath, err := fileutils.CreateTempDir()
330+
assert.NoError(t, err, "Couldn't create temp dir")
331+
actualPath := filepath.Join(filepath.Dir(tempDirPath), filepath.Base(projectPath))
332+
coreTests.RenamePath(tempDirPath, actualPath, t)
333+
assert.NoError(t, biutils.CopyDir(projectPath, actualPath, true, nil))
334+
return actualPath, func() {
335+
assert.NoError(t, fileutils.RemoveTempDir(actualPath), "Couldn't remove temp dir")
336+
}
336337
}
337338

338339
func CreateTestProjectEnvAndChdir(t *testing.T, projectPath string) (string, func()) {

0 commit comments

Comments
 (0)