aboutsummaryrefslogtreecommitdiffstats
path: root/tests/slskd.Tests.Unit/Common
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-06-05 19:18:18 -0500
committerJP Dillingham <jp@dillingham.me>2026-06-06 07:30:00 -0500
commit5ed58b906b98c0f1b06147ed4db18c9bc2f1ffdf (patch)
treea78841dea42b9abe73d538ff75382e457370067a /tests/slskd.Tests.Unit/Common
parent62134e78472a51ef0becff9c0850f635933ab506 (diff)
downloadslskd-5ed58b906b98c0f1b06147ed4db18c9bc2f1ffdf.tar.gz
small tweaks
Diffstat (limited to 'tests/slskd.Tests.Unit/Common')
-rw-r--r--tests/slskd.Tests.Unit/Common/FileSafety/CombineSafelyTests.cs32
-rw-r--r--tests/slskd.Tests.Unit/Common/Validation/RelativePathAttributeTests.cs2
2 files changed, 5 insertions, 29 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]