You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sonarr/src/NzbDrone.Core.Test/Datastore/Migration/075_force_lib_updateFixture.cs

108 lines
3.5 KiB

using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class force_lib_updateFixture : MigrationTest<force_lib_update>
{
[Test]
public void should_not_fail_on_empty_db()
{
var db = WithMigrationTestDb();
db.Query("SELECT * FROM \"ScheduledTasks\"").Should().BeEmpty();
db.Query("SELECT * FROM \"Series\"").Should().BeEmpty();
}
[Test]
public void should_reset_job_last_execution_time()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("ScheduledTasks").Row(new
{
TypeName = "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand",
Interval = 10,
LastExecution = "2000-01-01 00:00:00"
});
c.Insert.IntoTable("ScheduledTasks").Row(new
{
TypeName = "NzbDrone.Core.Backup.BackupCommand",
Interval = 10,
LastExecution = "2000-01-01 00:00:00"
});
});
var jobs = db.Query<ScheduledTasks75>("SELECT \"TypeName\", \"LastExecution\" FROM \"ScheduledTasks\"");
jobs.Single(c => c.TypeName == "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand")
.LastExecution.Year.Should()
.Be(2014);
jobs.Single(c => c.TypeName == "NzbDrone.Core.Backup.BackupCommand")
.LastExecution.Year.Should()
.Be(2000);
}
[Test]
public void should_reset_series_last_sync_time()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
Name = "Profile1",
Cutoff = 0,
Items = "[]",
Language = 1
});
c.Insert.IntoTable("Series").Row(new
{
TvdbId = 1,
TvRageId =1,
Title ="Title1",
CleanTitle ="CleanTitle1",
Status = 1,
Images = "",
Path = "c:\\test",
Monitored = true,
SeasonFolder = true,
Runtime = 0,
SeriesType = 0,
UseSceneNumbering = false,
LastInfoSync = "2000-01-01 00:00:00",
ProfileId = 1
});
c.Insert.IntoTable("Series").Row(new
{
TvdbId = 2,
TvRageId = 2,
Title = "Title2",
CleanTitle = "CleanTitle2",
Status = 1,
Images = "",
Path = "c:\\test2",
Monitored = true,
SeasonFolder = true,
Runtime = 0,
SeriesType = 0,
UseSceneNumbering = false,
LastInfoSync = "2000-01-01 00:00:00",
ProfileId = 1
});
});
var series = db.Query<Series69>("SELECT \"LastInfoSync\" FROM \"Series\"");
series.Should().OnlyContain(c => c.LastInfoSync.Value.Year == 2014);
}
}
}