1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 12:32:31 +01:00

last fix for deleted job didn't work, this should fix it.

This commit is contained in:
kay.one 2011-12-01 23:26:38 -08:00
parent 08a5b28f40
commit ce8713d953
2 changed files with 25 additions and 4 deletions

View File

@ -290,20 +290,41 @@ public void inti_should_removed_jobs_that_no_longer_exist()
{
IList<IJob> fakeJobs = new List<IJob> { fakeJob };
Mocker.SetConstant(fakeJobs);
WithRealDb();
var deletedJob = Builder<JobDefinition>.CreateNew().Build();
Db.Insert(deletedJob);
var jobProvider = Mocker.Resolve<JobProvider>();
//Act
jobProvider.Initialize();
//Assert
var registeredJobs = Db.Fetch<JobDefinition>();
registeredJobs.Should().HaveCount(1);
registeredJobs.Should().NotContain(c => c.Name == deletedJob.Name);
registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
}
[Test]
public void inti_should_removed_jobs_that_no_longer_exist_even_with_same_name()
{
IList<IJob> fakeJobs = new List<IJob> { fakeJob };
Mocker.SetConstant(fakeJobs);
WithRealDb();
var deletedJob = Builder<JobDefinition>.CreateNew()
.With(c => c.Name = fakeJob.Name).Build();
Db.Insert(deletedJob);
var jobProvider = Mocker.Resolve<JobProvider>();
//Act
jobProvider.Initialize();
//Assert
var registeredJobs = Db.Fetch<JobDefinition>();
registeredJobs.Should().HaveCount(1);
registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
}
[Test]

View File

@ -76,7 +76,7 @@ public virtual void Initialize()
foreach (var currentJob in currentJobs)
{
if (!_jobs.Any(c => c.Name == currentJob.Name))
if (!_jobs.Any(c => c.GetType().ToString() == currentJob.TypeName))
{
logger.Debug("Removing job from database '{0}'", currentJob.Name);
_database.Delete(currentJob);