Cleanup file related code (#14023)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Extensions.Tests;
|
||||
|
||||
public static class FileHelperTests
|
||||
{
|
||||
[Fact]
|
||||
public static void CreateEmpty_Valid_Correct()
|
||||
{
|
||||
var path = Path.Join(Path.GetTempPath(), Path.GetRandomFileName());
|
||||
var fileInfo = new FileInfo(path);
|
||||
|
||||
Assert.False(fileInfo.Exists);
|
||||
|
||||
FileHelper.CreateEmpty(path);
|
||||
|
||||
fileInfo.Refresh();
|
||||
Assert.True(fileInfo.Exists);
|
||||
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using AutoFixture;
|
||||
using Emby.Server.Implementations.Library;
|
||||
using Emby.Server.Implementations.Plugins;
|
||||
using Jellyfin.Extensions;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using Jellyfin.Extensions.Json.Converters;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
@@ -85,7 +86,7 @@ namespace Jellyfin.Server.Implementations.Tests.Plugins
|
||||
var dllPath = Path.GetDirectoryName(Path.Combine(_pluginPath, dllFile))!;
|
||||
|
||||
Directory.CreateDirectory(dllPath);
|
||||
File.Create(Path.Combine(dllPath, filename));
|
||||
FileHelper.CreateEmpty(Path.Combine(dllPath, filename));
|
||||
var metafilePath = Path.Combine(_pluginPath, "meta.json");
|
||||
|
||||
File.WriteAllText(metafilePath, JsonSerializer.Serialize(manifest, _options));
|
||||
@@ -141,7 +142,7 @@ namespace Jellyfin.Server.Implementations.Tests.Plugins
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
File.Create(Path.Combine(_pluginPath, file));
|
||||
FileHelper.CreateEmpty(Path.Combine(_pluginPath, file));
|
||||
}
|
||||
|
||||
var metafilePath = Path.Combine(_pluginPath, "meta.json");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.IO;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
@@ -33,7 +34,7 @@ namespace Jellyfin.Server.Integration.Tests
|
||||
// Write out for publishing
|
||||
string outputPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "openapi.json"));
|
||||
_outputHelper.WriteLine("Writing OpenAPI Spec JSON to '{0}'.", outputPath);
|
||||
await using var fs = File.Create(outputPath);
|
||||
await using var fs = AsyncFile.Create(outputPath);
|
||||
await response.Content.CopyToAsync(fs);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user