From 8ec1493d55fa071a7c0fae4ff920e7d7d4fdbe41 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Thu, 5 Feb 2026 15:18:11 +0100 Subject: [PATCH] Fixed tests also working on Windows --- Duplicati/UnitTest/DuplicatePathTests.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Duplicati/UnitTest/DuplicatePathTests.cs b/Duplicati/UnitTest/DuplicatePathTests.cs index 6a58c504c..43c859f00 100644 --- a/Duplicati/UnitTest/DuplicatePathTests.cs +++ b/Duplicati/UnitTest/DuplicatePathTests.cs @@ -73,13 +73,16 @@ namespace Duplicati.UnitTest // Get the FileID for our test file // The "File" view already combines Prefix + Path // We need to search for the path ending with our filename - var searchPath = "/duplicate.txt"; + // Use Path.Combine for cross-platform path handling + var searchPath = Path.Combine(DATAFOLDER, "duplicate.txt"); + // Normalize path separators for the database query + searchPath = searchPath.Replace(Path.DirectorySeparatorChar, '/'); cmd.CommandText = @" SELECT ""ID"" FROM ""File"" - WHERE ""Path"" LIKE @Path + WHERE ""Path"" = @Path ORDER BY ""ID"" DESC LIMIT 1 "; - cmd.Parameters.AddWithValue("@Path", "%" + searchPath); + cmd.Parameters.AddWithValue("@Path", searchPath); var fileId = Convert.ToInt64(await cmd.ExecuteScalarAsync() ?? 0); Assert.Greater(fileId, 0, "Should have a file entry"); @@ -286,13 +289,16 @@ namespace Duplicati.UnitTest // Get the FileID for our test file // The "File" view already combines Prefix + Path - var searchPath = "/test.txt"; + // Use Path.Combine for cross-platform path handling + var searchPath = Path.Combine(DATAFOLDER, "test.txt"); + // Normalize path separators for the database query + searchPath = searchPath.Replace(Path.DirectorySeparatorChar, '/'); cmd.CommandText = @" SELECT ""ID"" FROM ""File"" - WHERE ""Path"" LIKE @Path + WHERE ""Path"" = @Path ORDER BY ""ID"" DESC LIMIT 1 "; - cmd.Parameters.AddWithValue("@Path", "%" + searchPath); + cmd.Parameters.AddWithValue("@Path", searchPath); var fileId = Convert.ToInt64(await cmd.ExecuteScalarAsync() ?? 0); // Get the existing FileLookup entry details to create a duplicate