1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-26 09:47:39 +00:00

Merge pull request #176 from Sonarr/force-series-refresh

forcing lib update on upgrade
This commit is contained in:
Keivan Beigi 2015-01-18 10:51:02 -08:00
commit 11728936f4
4 changed files with 124 additions and 0 deletions

View file

@ -0,0 +1,100 @@
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class force_lib_updateFixture : MigrationTest<Core.Datastore.Migration.force_lib_update>
{
[Test]
public void should_not_fail_on_empty_db()
{
WithTestDb(c => { });
Mocker.Resolve<ScheduledTaskRepository>().All().Should().BeEmpty();
Mocker.Resolve<SeriesRepository>().All().Should().BeEmpty();
}
[Test]
public void should_reset_job_last_execution_time()
{
WithTestDb(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 = Mocker.Resolve<ScheduledTaskRepository>().All().ToList();
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()
{
WithTestDb(c =>
{
c.Insert.IntoTable("Series").Row(new
{
Tvdbid = 1,
TvRageId =1,
Title ="Title1",
CleanTitle ="CleanTitle1",
Status =1,
Images ="",
Path ="c:\\test",
Monitored =1,
SeasonFolder =1,
Runtime= 0,
SeriesType=0,
UseSceneNumbering =0,
LastInfoSync = "2000-01-01 00:00:00"
});
c.Insert.IntoTable("Series").Row(new
{
Tvdbid = 2,
TvRageId = 2,
Title = "Title2",
CleanTitle = "CleanTitle2",
Status = 1,
Images = "",
Path = "c:\\test2",
Monitored = 1,
SeasonFolder = 1,
Runtime = 0,
SeriesType = 0,
UseSceneNumbering = 0,
LastInfoSync = "2000-01-01 00:00:00"
});
});
var jobs = Mocker.Resolve<SeriesRepository>().All().ToList();
jobs.Should().OnlyContain(c => c.LastInfoSync.Value.Year == 2014);
}
}
}

View file

@ -120,6 +120,7 @@
<Compile Include="Datastore\Migration\074_disable_eztv.cs" />
<Compile Include="Datastore\Migration\072_history_grabIdFixture.cs" />
<Compile Include="Datastore\Migration\070_delay_profileFixture.cs" />
<Compile Include="Datastore\Migration\075_force_lib_updateFixture.cs" />
<Compile Include="Datastore\ObjectDatabaseFixture.cs" />
<Compile Include="Datastore\PagingSpecExtensionsTests\PagingOffsetFixture.cs" />
<Compile Include="Datastore\PagingSpecExtensionsTests\ToSortDirectionFixture.cs" />

View file

@ -0,0 +1,22 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(75)]
public class force_lib_update : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Update.Table("ScheduledTasks")
.Set(new { LastExecution = "2014-01-01 00:00:00" })
.Where(new { TypeName = "NzbDrone.Core.Tv.Commands.RefreshSeriesCommand" });
Update.Table("Series")
.Set(new { LastInfoSync = "2014-01-01 00:00:00" })
.AllRows();
}
}
}

View file

@ -232,6 +232,7 @@
<Compile Include="Datastore\Migration\069_quality_proper.cs" />
<Compile Include="Datastore\Migration\071_unknown_quality_in_profile.cs" />
<Compile Include="Datastore\Migration\072_history_grabid.cs" />
<Compile Include="Datastore\Migration\075_force_lib_update.cs" />
<Compile Include="Datastore\Migration\074_disable_eztv.cs" />
<Compile Include="Datastore\Migration\073_clear_ratings.cs" />
<Compile Include="Datastore\Migration\070_delay_profile.cs" />