test: cover watch-time tracking, notices and storage
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Jellyfin.Plugin.Herald.Storage;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace Jellyfin.Plugin.Herald.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// A database in a throwaway directory.
|
||||
/// </summary>
|
||||
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<HeraldDatabase>.Instance);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SqliteConnection.ClearAllPools();
|
||||
if (Directory.Exists(_directory))
|
||||
{
|
||||
Directory.Delete(_directory, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user