mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-29 11:05:44 +00:00
Added test to make sure disabled jobs aren't actually running automatically
This commit is contained in:
parent
2f786bf424
commit
13f37cd405
2 changed files with 30 additions and 1 deletions
|
@ -313,6 +313,32 @@ public void Get_Next_Execution_Time()
|
||||||
Assert.IsNotEmpty(settings);
|
Assert.IsNotEmpty(settings);
|
||||||
Assert.AreEqual(next, settings[0].LastExecution.AddMinutes(15));
|
Assert.AreEqual(next, settings[0].LastExecution.AddMinutes(15));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Disabled_isnt_run_by_scheduler()
|
||||||
|
{
|
||||||
|
var repo = MockLib.GetEmptyRepository();
|
||||||
|
|
||||||
|
|
||||||
|
var disabledJob = new DisabledJob();
|
||||||
|
IEnumerable<IJob> fakeJobs = new List<IJob> { disabledJob };
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
mocker.SetConstant(repo);
|
||||||
|
mocker.SetConstant(fakeJobs);
|
||||||
|
|
||||||
|
var timerProvider = mocker.Resolve<JobProvider>();
|
||||||
|
timerProvider.Initialize();
|
||||||
|
|
||||||
|
timerProvider.RunScheduled();
|
||||||
|
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(0, disabledJob.ExexutionCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FakeJob : IJob
|
public class FakeJob : IJob
|
||||||
|
@ -345,9 +371,11 @@ public int DefaultInterval
|
||||||
get { return 0; }
|
get { return 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int ExexutionCount { get; set; }
|
||||||
|
|
||||||
public void Start(ProgressNotification notification, int targetId)
|
public void Start(ProgressNotification notification, int targetId)
|
||||||
{
|
{
|
||||||
|
ExexutionCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ public virtual bool RunScheduled()
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Debug("Finished executing scheduled tasks.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue