diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-06-05 19:18:18 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-06-06 07:45:22 -0500 |
| commit | 12cf9ad6b33ae29e9e7caea20b205fadd45798bf (patch) | |
| tree | 3c185c49812d427faf8d0cb9c0134c759a984f4c /tests/slskd.Tests.Unit | |
| parent | 62134e78472a51ef0becff9c0850f635933ab506 (diff) | |
| download | slskd-12cf9ad6b33ae29e9e7caea20b205fadd45798bf.tar.gz | |
small tweaks
Diffstat (limited to 'tests/slskd.Tests.Unit')
4 files changed, 7 insertions, 33 deletions
diff --git a/tests/slskd.Tests.Unit/Common/FileSafety/CombineSafelyTests.cs b/tests/slskd.Tests.Unit/Common/FileSafety/CombineSafelyTests.cs index c3b69b12..e40ce743 100644 --- a/tests/slskd.Tests.Unit/Common/FileSafety/CombineSafelyTests.cs +++ b/tests/slskd.Tests.Unit/Common/FileSafety/CombineSafelyTests.cs @@ -169,21 +169,9 @@ public partial class FileSafetyTests [InlineData("C:relative")] public void Accepts_Colon_In_Segment_On_Linux_Hits_Backstop_On_Windows(string segment) { - var result = Record.Exception(() => FileSafety.CombineSafely(Base, OperatingSystem.Linux, segment)); + var result = FileSafety.CombineSafely(Base, OperatingSystem.Linux, segment); - if (!System.OperatingSystem.IsWindows()) - { - Assert.Null(result); - } - else - { - // this test breaks when run on windows - // this is valid on linux (which we're trying to test for) - // but invalid on windows because it is a drive-relative path and it successfully traverses - Assert.NotNull(result); - Assert.IsType<ArgumentException>(result); - Assert.Contains("traversal detected", result.Message); - } + Assert.Equal($"{Base}/C:relative", result); } [Theory] @@ -201,21 +189,9 @@ public partial class FileSafetyTests [InlineData("\\Music")] public void Accepts_Leading_Backslash_In_Segment_On_Linux(string segment) { - var result = Record.Exception(() => FileSafety.CombineSafely(Base, OperatingSystem.Linux, segment)); + var result = FileSafety.CombineSafely(Base, OperatingSystem.Linux, segment); - if (!System.OperatingSystem.IsWindows()) - { - Assert.Null(result); - } - else - { - // this test breaks when run on windows - // this is valid on linux (which we're trying to test for) - // but invalid on windows because it is a drive-relative path and it successfully traverses - Assert.NotNull(result); - Assert.IsType<ArgumentException>(result); - Assert.Contains("traversal detected", result.Message); - } + Assert.Equal($"{Base}/\\Music", result); } [Fact] diff --git a/tests/slskd.Tests.Unit/Common/Validation/RelativePathAttributeTests.cs b/tests/slskd.Tests.Unit/Common/Validation/RelativePathAttributeTests.cs index 8d1c16b3..ea74f822 100644 --- a/tests/slskd.Tests.Unit/Common/Validation/RelativePathAttributeTests.cs +++ b/tests/slskd.Tests.Unit/Common/Validation/RelativePathAttributeTests.cs @@ -130,7 +130,7 @@ public class RelativePathAttributeTests // Note: the implementation uses the same message for Current as for Any/All. // "on all operating systems" is misleading here since Current only validates // against the current (or injected) OS. - Assert.Equal("The Field field must be a relative path on all operating systems.", msg); + Assert.Equal("The Field field must be a relative path on the current operating system.", msg); } [Fact] diff --git a/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs b/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs index 4d4e4969..f608467b 100644 --- a/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs +++ b/tests/slskd.Tests.Unit/Transfers/API/DTO/QueueDownloadBatchRequestTests.cs @@ -285,7 +285,7 @@ public class QueueDownloadBatchRequestTests var (isValid, results) = Validate(new EnqueueDownloadBatchOptions { Destination = value }); Assert.False(isValid); Assert.Single(results); - Assert.Equal("The Destination field must be a relative path.", results[0].ErrorMessage); + Assert.Contains("must be a relative path", results[0].ErrorMessage); } } @@ -300,7 +300,7 @@ public class QueueDownloadBatchRequestTests var (isValid, results) = Validate(new EnqueueDownloadBatchOptions { Destination = value }); Assert.False(isValid); Assert.Single(results); - Assert.Equal("The Destination field must be a relative path.", results[0].ErrorMessage); + Assert.Contains("must be a relative path", results[0].ErrorMessage); } } diff --git a/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/DeriveDestinationTests.cs b/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/DeriveDestinationTests.cs index 4da05b24..f35ff452 100644 --- a/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/DeriveDestinationTests.cs +++ b/tests/slskd.Tests.Unit/Transfers/Downloads/DownloadService/DeriveDestinationTests.cs @@ -499,7 +499,6 @@ public partial class DownloadServiceTests [Fact] public async Task SEARCH_TEXT_Is_Fallback_When_Search_Text_Is_Empty() { - // fails until code uses IsNullOrWhiteSpace instead of ?? for search_text (parity with batch_external_id) var searchId = Guid.NewGuid(); var batchId = Guid.NewGuid(); var batch = new Batch { Id = batchId, SearchId = searchId }; @@ -513,7 +512,6 @@ public partial class DownloadServiceTests [Fact] public async Task SEARCH_TEXT_Is_Fallback_When_Search_Text_Is_Whitespace() { - // fails until code uses IsNullOrWhiteSpace instead of ?? for search_text (parity with batch_external_id) var searchId = Guid.NewGuid(); var batchId = Guid.NewGuid(); var batch = new Batch { Id = batchId, SearchId = searchId }; |
