mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 12:32:31 +01:00
Fixed job provider existing job update bug.
This commit is contained in:
parent
98e8f4361e
commit
a7a7c4ab49
@ -313,7 +313,7 @@ public void inti_should_removed_jobs_that_no_longer_exist_even_with_same_name()
|
||||
WithRealDb();
|
||||
var deletedJob = Builder<JobDefinition>.CreateNew()
|
||||
.With(c => c.Name = fakeJob.Name).Build();
|
||||
|
||||
|
||||
Db.Insert(deletedJob);
|
||||
var jobProvider = Mocker.Resolve<JobProvider>();
|
||||
|
||||
@ -334,9 +334,12 @@ public void init_should_update_existing_job()
|
||||
|
||||
WithRealDb();
|
||||
var initialFakeJob = Builder<JobDefinition>.CreateNew()
|
||||
.With(c => c.Name = fakeJob.Name)
|
||||
.With(c => c.Name = "NewName")
|
||||
.With(c => c.TypeName = fakeJob.GetType().ToString())
|
||||
.With(c => c.Interval = 60)
|
||||
.With(c => c.Interval = 0)
|
||||
.With(c => c.Enable = false)
|
||||
.With(c => c.Success = true)
|
||||
.With(c => c.LastExecution = DateTime.Now.AddDays(-7).Date)
|
||||
.Build();
|
||||
|
||||
var id = Convert.ToInt32(Db.Insert(initialFakeJob));
|
||||
@ -349,8 +352,13 @@ public void init_should_update_existing_job()
|
||||
//Assert
|
||||
var registeredJobs = Db.Fetch<JobDefinition>();
|
||||
registeredJobs.Should().HaveCount(1);
|
||||
registeredJobs.First().TypeName.Should().Be(fakeJob.GetType().ToString());
|
||||
registeredJobs.First().Name.Should().Be(fakeJob.Name);
|
||||
registeredJobs.First().Interval.Should().Be(fakeJob.DefaultInterval);
|
||||
registeredJobs.First().Id.Should().Be(id);
|
||||
|
||||
registeredJobs.First().Enable.Should().Be(true);
|
||||
registeredJobs.First().Success.Should().Be(initialFakeJob.Success);
|
||||
registeredJobs.First().LastExecution.Should().Be(initialFakeJob.LastExecution);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -85,23 +85,20 @@ public virtual void Initialize()
|
||||
|
||||
foreach (var job in _jobs)
|
||||
{
|
||||
var jobLocal = job;
|
||||
var jobDefinition = currentJobs.SingleOrDefault(c => c.TypeName == job.GetType().ToString());
|
||||
|
||||
var settings = new JobDefinition
|
||||
if (jobDefinition == null)
|
||||
{
|
||||
Enable = jobLocal.DefaultInterval > 0,
|
||||
TypeName = job.GetType().ToString(),
|
||||
Name = jobLocal.Name,
|
||||
Interval = jobLocal.DefaultInterval,
|
||||
LastExecution = DateTime.Now
|
||||
};
|
||||
|
||||
if (currentJobs.Exists(c => c.TypeName == jobLocal.GetType().ToString()))
|
||||
{
|
||||
settings.Id = currentJobs.Single(c => c.TypeName == jobLocal.GetType().ToString()).Id;
|
||||
jobDefinition = new JobDefinition();
|
||||
jobDefinition.TypeName = job.GetType().ToString();
|
||||
jobDefinition.LastExecution = DateTime.Now;
|
||||
}
|
||||
|
||||
SaveDefinition(settings);
|
||||
jobDefinition.Enable = job.DefaultInterval > 0;
|
||||
jobDefinition.Name = job.Name;
|
||||
jobDefinition.Interval = job.DefaultInterval;
|
||||
|
||||
SaveDefinition(jobDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user