feat(mosstank): add VTank-style automation PoC
This commit is contained in:
parent
f6fe0f2a4f
commit
4e6e9bc9d9
212 changed files with 49462 additions and 416 deletions
35
tests/AcDream.App.Tests/Plugins/FilePluginStorageTests.cs
Normal file
35
tests/AcDream.App.Tests/Plugins/FilePluginStorageTests.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using AcDream.App.Plugins;
|
||||
|
||||
namespace AcDream.App.Tests.Plugins;
|
||||
|
||||
public sealed class FilePluginStorageTests
|
||||
{
|
||||
[Fact]
|
||||
public void WriteReadReplaceAndDeleteStayUnderConfiguredRoot()
|
||||
{
|
||||
string root = Path.Combine(
|
||||
Path.GetTempPath(),
|
||||
$"acdream-plugin-storage-{Guid.NewGuid():N}");
|
||||
try
|
||||
{
|
||||
var storage = new FilePluginStorage(root);
|
||||
storage.WriteText("plugin/profile.json", "one");
|
||||
storage.WriteText("plugin/imports/route.nav", "nav");
|
||||
Assert.Equal("one", storage.ReadText("plugin/profile.json"));
|
||||
storage.WriteText("plugin/profile.json", "two");
|
||||
Assert.Equal("two", storage.ReadText("plugin/profile.json"));
|
||||
Assert.Equal(
|
||||
["plugin/imports/route.nav"],
|
||||
storage.List("plugin/imports"));
|
||||
Assert.True(storage.Delete("plugin/profile.json"));
|
||||
Assert.Null(storage.ReadText("plugin/profile.json"));
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
storage.WriteText("../escape.json", "bad"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(root))
|
||||
Directory.Delete(root, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue