test: cover watch-time tracking, notices and storage

This commit is contained in:
2026-11-13 18:10:41 +01:00
parent 1cc93c5250
commit 66593e9da2
9 changed files with 863 additions and 0 deletions
@@ -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);
}
}
}