using Jellyfin.Plugin.Herald.Storage; using Microsoft.Data.Sqlite; using Microsoft.Extensions.Logging.Abstractions; namespace Jellyfin.Plugin.Herald.Tests; /// /// A database in a throwaway directory. /// public sealed class TempDatabase : IDisposable { private readonly string _directory = Path.Combine(Path.GetTempPath(), "herald-tests-" + Guid.NewGuid().ToString("N")); public TempDatabase() { Database = Open(); } public HeraldDatabase Database { get; } public string FilePath => Path.Combine(_directory, "nested", "herald.db"); public HeraldDatabase Open() => new(FilePath, NullLogger.Instance); public void Dispose() { SqliteConnection.ClearAllPools(); if (Directory.Exists(_directory)) { Directory.Delete(_directory, true); } } }