mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
More updates to Datastore
This commit is contained in:
parent
76d029361b
commit
ecc2a7e2f6
6 changed files with 131 additions and 50 deletions
|
@ -5,6 +5,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using Moq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
@ -34,25 +35,30 @@ namespace NzbDrone.Core.Test.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public static IRepository GetEmptyRepository()
|
||||
{
|
||||
return GetEmptyRepository(false);
|
||||
}
|
||||
|
||||
public static IRepository GetEmptyRepository(bool enableLogging)
|
||||
public static IRepository GetEmptyRepository(bool enableLogging = false, string fileName = "")
|
||||
{
|
||||
Console.WriteLine("Creating an empty SQLite database");
|
||||
var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True",
|
||||
"System.Data.SQLite");
|
||||
|
||||
var repo = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
|
||||
if (String.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
fileName = Guid.NewGuid() + ".db";
|
||||
}
|
||||
|
||||
|
||||
var provider = Connection.GetDataProvider(Connection.GetConnectionString(fileName));
|
||||
var repo = Connection.CreateSimpleRepository(provider);
|
||||
ForceMigration(repo);
|
||||
|
||||
Migrations.Run(Connection.GetConnectionString(fileName), false);
|
||||
|
||||
if (enableLogging)
|
||||
{
|
||||
provider.Log = new NlogWriter();
|
||||
}
|
||||
|
||||
Console.WriteLine("**********************************************************************************");
|
||||
Console.WriteLine("*****************************REPO IS READY****************************************");
|
||||
Console.WriteLine("**********************************************************************************");
|
||||
return repo;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue