diff options
| author | Daniel <107576740+maskedmaxx@users.noreply.github.com> | 2026-05-20 20:55:17 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-20 20:55:17 -0400 |
| commit | 96b62ac8596a8ba2c028b88964ff76a8aad3e5bf (patch) | |
| tree | b55aa04d606b258b32fd48c1183507a4a16c090d /tests/slskd.Tests.Unit/Core | |
| parent | 61703575cf9038f6a0de89bb5b9be44431439618 (diff) | |
| parent | 03b35a5ababfd7bc2d0af053d8622a14cdd6b8fe (diff) | |
| download | slskd-96b62ac8596a8ba2c028b88964ff76a8aad3e5bf.tar.gz | |
Merge branch 'master' into fix/issue-1726-relay-controller-trailing-slash
Diffstat (limited to 'tests/slskd.Tests.Unit/Core')
| -rw-r--r-- | tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs | 40 |
1 files changed, 40 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..7eacb95d --- /dev/null +++ b/tests/slskd.Tests.Unit/Core/Options/SharesOptionsTests.cs @@ -0,0 +1,40 @@ +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]/"] + }; + + // todo: fix this so that it fully validates on all platforms; currently this fails + // validation on Windows and would fail on Linux if i were to use backslashes + // the assertion for the alias proves we have fixed an aliasing bug so it's fine for now + var results = Validate(options); + + Assert.DoesNotContain(results, r => r.ErrorMessage?.Contains("aliases may not contain path separators") == true); + } + } + } +} |
