aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-05-17 17:39:43 -0500
committerJP Dillingham <jp@dillingham.me>2026-05-17 17:39:43 -0500
commit3c799f205ce56e250883efd1deda798b758bb788 (patch)
tree5c98576cfbafea9f7890051233512be47a09006e /tests
parent6f0d9682fde688cf1fd8d3f330aca71616f28a9f (diff)
downloadslskd-3c799f205ce56e250883efd1deda798b758bb788.tar.gz
add test for greedy bracket change
Diffstat (limited to 'tests')
-rw-r--r--tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs b/tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs
new file mode 100644
index 00000000..35ff53e6
--- /dev/null
+++ b/tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs
@@ -0,0 +1,37 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using Xunit;
+using static slskd.Options;
+
+namespace slskd.Tests.Unit.Core.Options;
+
+public class SharesOptionsTests
+{
+ private static List<ValidationResult> Validate(SharesOptions options)
+ {
+ var context = new ValidationContext(options);
+ var results = new List<ValidationResult>();
+ Validator.TryValidateObject(options, context, results, validateAllProperties: true);
+ return results;
+ }
+
+ public class Directories
+ {
+ public class Digest
+ {
+ [Fact]
+ public void Alias_Uses_First_Closing_Bracket_When_Path_Contains_Brackets()
+ {
+ // [foo]/bar/[baz]/ should digest to alias "foo" and path "/bar/[baz]"
+ var options = new SharesOptions
+ {
+ Directories = [@"[foo]/bar/[baz]/"]
+ };
+
+ var results = Validate(options);
+
+ Assert.DoesNotContain(results, r => r.ErrorMessage?.Contains("aliases may not contain path separators") == true);
+ }
+ }
+ }
+}