mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-12 22:12:38 +01:00
last fix for deleted job didn't work, this should fix it.
This commit is contained in:
parent
08a5b28f40
commit
ce8713d953
@ -290,20 +290,41 @@ public void inti_should_removed_jobs_that_no_longer_exist()
|
|||||||
{
|
{
|
||||||
IList<IJob> fakeJobs = new List<IJob> { fakeJob };
|
IList<IJob> fakeJobs = new List<IJob> { fakeJob };
|
||||||
Mocker.SetConstant(fakeJobs);
|
Mocker.SetConstant(fakeJobs);
|
||||||
|
|
||||||
WithRealDb();
|
WithRealDb();
|
||||||
var deletedJob = Builder<JobDefinition>.CreateNew().Build();
|
var deletedJob = Builder<JobDefinition>.CreateNew().Build();
|
||||||
Db.Insert(deletedJob);
|
Db.Insert(deletedJob);
|
||||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
jobProvider.Initialize();
|
jobProvider.Initialize();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
var registeredJobs = Db.Fetch<JobDefinition>();
|
var registeredJobs = Db.Fetch<JobDefinition>();
|
||||||
registeredJobs.Should().HaveCount(1);
|
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]
|
[Test]
|
||||||
|
@ -76,7 +76,7 @@ public virtual void Initialize()
|
|||||||
|
|
||||||
foreach (var currentJob in currentJobs)
|
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);
|
logger.Debug("Removing job from database '{0}'", currentJob.Name);
|
||||||
_database.Delete(currentJob);
|
_database.Delete(currentJob);
|
||||||
|
Loading…
Reference in New Issue
Block a user