feat: add fnOS packaging, storage workflows and release pipeline
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using dy.net.storage;
|
||||
|
||||
namespace dy.net.Tests;
|
||||
|
||||
public class StoragePathTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null, "/")]
|
||||
[InlineData("", "/")]
|
||||
[InlineData(" ", "/")]
|
||||
[InlineData("/", "/")]
|
||||
[InlineData("///", "/")]
|
||||
public void NormalizeRemote_NormalizesEmptyAndRootPaths(string input, string expected)
|
||||
{
|
||||
Assert.Equal(expected, StoragePath.NormalizeRemote(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("\\media\\author\\video.mp4", "/media/author/video.mp4")]
|
||||
[InlineData("//media///author/video.mp4/", "/media/author/video.mp4")]
|
||||
[InlineData(" media/author/video.mp4 ", "/media/author/video.mp4")]
|
||||
public void NormalizeRemote_NormalizesSeparators(string input, string expected)
|
||||
{
|
||||
Assert.Equal(expected, StoragePath.NormalizeRemote(input));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CombineRemote_JoinsRemoteSegments()
|
||||
{
|
||||
Assert.Equal("/base/account/video.mp4", StoragePath.CombineRemote("/base/", null, "account", "/video.mp4"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Encode_EncodesUnicodeSpacesAndReservedCharactersPerSegment()
|
||||
{
|
||||
Assert.Equal("/%E4%B8%AD%E6%96%87%20folder/video%20%231.mp4", StoragePath.Encode("/中文 folder/video #1.mp4"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/", "/")]
|
||||
[InlineData("/video.mp4", "/")]
|
||||
[InlineData("/media/author/video.mp4", "/media/author")]
|
||||
public void DirectoryName_ReturnsRemoteParent(string input, string expected)
|
||||
{
|
||||
Assert.Equal(expected, StoragePath.DirectoryName(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/./video.mp4")]
|
||||
[InlineData("/media/../video.mp4")]
|
||||
[InlineData("..\\video.mp4")]
|
||||
public void NormalizeRemote_RejectsTraversalSegments(string input)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => StoragePath.NormalizeRemote(input));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user