mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 15:48:03 +00:00
Cleanup file related code (#14023)
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI / OpenAPI - HEAD (push) Waiting to run
OpenAPI / OpenAPI - BASE (push) Waiting to run
OpenAPI / OpenAPI - Difference (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI / OpenAPI - HEAD (push) Waiting to run
OpenAPI / OpenAPI - BASE (push) Waiting to run
OpenAPI / OpenAPI - Difference (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
This commit is contained in:
23
tests/Jellyfin.Extensions.Tests/FileHelperTests.cs
Normal file
23
tests/Jellyfin.Extensions.Tests/FileHelperTests.cs
Normal file
@@ -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