|
|
|
@ -41,13 +41,13 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
|
Subject.Init();
|
|
|
|
|
|
|
|
|
|
Storage.All().Should().HaveCount(1);
|
|
|
|
|
Storage.All().ToList()[0].Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes);
|
|
|
|
|
Storage.All().ToList()[0].Name.Should().Be(_fakeJob.Name);
|
|
|
|
|
Storage.All().ToList()[0].TypeName.Should().Be(_fakeJob.GetType().ToString());
|
|
|
|
|
Storage.All().ToList()[0].LastExecution.Should().HaveYear(DateTime.Now.Year);
|
|
|
|
|
Storage.All().ToList()[0].LastExecution.Should().HaveMonth(DateTime.Now.Month);
|
|
|
|
|
Storage.All().ToList()[0].LastExecution.Should().HaveDay(DateTime.Today.Day);
|
|
|
|
|
Storage.All().ToList()[0].Enable.Should().BeTrue();
|
|
|
|
|
StoredModel.Interval.Should().Be((Int32)_fakeJob.DefaultInterval.TotalMinutes);
|
|
|
|
|
StoredModel.Name.Should().Be(_fakeJob.Name);
|
|
|
|
|
StoredModel.TypeName.Should().Be(_fakeJob.GetType().ToString());
|
|
|
|
|
StoredModel.LastExecution.Should().HaveYear(DateTime.Now.Year);
|
|
|
|
|
StoredModel.LastExecution.Should().HaveMonth(DateTime.Now.Month);
|
|
|
|
|
StoredModel.LastExecution.Should().HaveDay(DateTime.Today.Day);
|
|
|
|
|
StoredModel.Enable.Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -65,9 +65,8 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
|
Db.Insert(deletedJob);
|
|
|
|
|
Subject.Init();
|
|
|
|
|
|
|
|
|
|
var registeredJobs = Storage.All();
|
|
|
|
|
registeredJobs.Should().HaveCount(1);
|
|
|
|
|
registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
|
|
|
|
|
AllStoredModels.Should().HaveCount(1);
|
|
|
|
|
AllStoredModels.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -88,10 +87,8 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
|
Subject.Init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var registeredJobs = Storage.All();
|
|
|
|
|
registeredJobs.Should().HaveCount(1);
|
|
|
|
|
registeredJobs.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
|
|
|
|
|
AllStoredModels.Should().HaveCount(1);
|
|
|
|
|
AllStoredModels.Should().NotContain(c => c.TypeName == deletedJob.TypeName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -118,15 +115,13 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
|
Subject.Init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var registeredJobs = Storage.All();
|
|
|
|
|
registeredJobs.Should().HaveCount(1);
|
|
|
|
|
registeredJobs.First().TypeName.Should().Be(newJob.GetType().FullName);
|
|
|
|
|
registeredJobs.First().Name.Should().Be(newJob.Name);
|
|
|
|
|
registeredJobs.First().Interval.Should().Be((int)newJob.DefaultInterval.TotalMinutes);
|
|
|
|
|
|
|
|
|
|
registeredJobs.First().Enable.Should().Be(true);
|
|
|
|
|
registeredJobs.First().Success.Should().Be(oldJob.Success);
|
|
|
|
|
registeredJobs.First().LastExecution.Should().Be(oldJob.LastExecution);
|
|
|
|
|
AllStoredModels.Should().HaveCount(1);
|
|
|
|
|
StoredModel.TypeName.Should().Be(newJob.GetType().FullName);
|
|
|
|
|
StoredModel.Name.Should().Be(newJob.Name);
|
|
|
|
|
StoredModel.Interval.Should().Be((int)newJob.DefaultInterval.TotalMinutes);
|
|
|
|
|
StoredModel.Enable.Should().Be(true);
|
|
|
|
|
StoredModel.Success.Should().Be(oldJob.Success);
|
|
|
|
|
StoredModel.LastExecution.Should().Be(oldJob.LastExecution);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
@ -142,6 +137,44 @@ namespace NzbDrone.Core.Test.JobTests
|
|
|
|
|
Storage.All().First().Enable.Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void pending_job_should_get_jobs_that_have_matured()
|
|
|
|
|
{
|
|
|
|
|
var oldJob = Builder<JobDefinition>.CreateNew()
|
|
|
|
|
.With(c => c.Id = 0)
|
|
|
|
|
.With(c => c.Interval = 1)
|
|
|
|
|
.With(c => c.Enable = true)
|
|
|
|
|
.With(c => c.Success = true)
|
|
|
|
|
.With(c => c.LastExecution = DateTime.Now.AddMinutes(-5))
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Storage.Insert(oldJob);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.GetPendingJobs().Should().HaveCount(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void pending_job_should_not_get_jobs_that_havent_matured()
|
|
|
|
|
{
|
|
|
|
|
var recent = Builder<JobDefinition>.CreateNew()
|
|
|
|
|
.With(c => c.Id = 0)
|
|
|
|
|
.With(c => c.Interval = 60)
|
|
|
|
|
.With(c => c.Enable = true)
|
|
|
|
|
.With(c => c.Success = true)
|
|
|
|
|
.With(c => c.LastExecution = DateTime.Now.AddMinutes(-5))
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Storage.Insert(recent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.GetPendingJobs().Should().BeEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [Test]
|
|
|
|
|
public void disabled_jobs_arent_run_by_scheduler()
|
|
|
|
|
{
|
|
|
|
|