mirror of https://github.com/Sonarr/Sonarr
fixed broken tests
This commit is contained in:
parent
4c810ca607
commit
c59fe4e674
|
@ -7,7 +7,7 @@ namespace NzbDrone.Api.SignalR
|
|||
public class Serializer : IJsonSerializer
|
||||
{
|
||||
private readonly Common.IJsonSerializer _nzbDroneSerializer;
|
||||
private JsonNetSerializer _signalRSerializer;
|
||||
private readonly JsonNetSerializer _signalRSerializer;
|
||||
|
||||
public Serializer(Common.IJsonSerializer nzbDroneSerializer)
|
||||
{
|
||||
|
|
|
@ -11,16 +11,13 @@ using NzbDrone.Test.Dummy;
|
|||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class ProcessProviderTests : TestBase
|
||||
public class ProcessProviderTests : TestBase<ProcessProvider>
|
||||
{
|
||||
|
||||
ProcessProvider _processProvider;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Process.GetProcessesByName(DummyApp.DUMMY_PROCCESS_NAME).ToList().ForEach(c => c.Kill());
|
||||
_processProvider = new ProcessProvider();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
@ -33,14 +30,14 @@ namespace NzbDrone.Common.Test
|
|||
[TestCase(123332324)]
|
||||
public void Kill_should_not_fail_on_invalid_process_is(int processId)
|
||||
{
|
||||
_processProvider.Kill(processId);
|
||||
Subject.Kill(processId);
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetById_should_return_null_if_process_doesnt_exist()
|
||||
{
|
||||
_processProvider.GetProcessById(1234567).Should().BeNull();
|
||||
Subject.GetProcessById(1234567).Should().BeNull();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
@ -50,7 +47,7 @@ namespace NzbDrone.Common.Test
|
|||
[TestCase(9999)]
|
||||
public void GetProcessById_should_return_null_for_invalid_process(int processId)
|
||||
{
|
||||
_processProvider.GetProcessById(processId).Should().BeNull();
|
||||
Subject.GetProcessById(processId).Should().BeNull();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
@ -59,7 +56,7 @@ namespace NzbDrone.Common.Test
|
|||
public void Should_be_able_to_kill_procces()
|
||||
{
|
||||
var dummyProcess = StartDummyProcess();
|
||||
_processProvider.Kill(dummyProcess.Id);
|
||||
Subject.Kill(dummyProcess.Id);
|
||||
dummyProcess.HasExited.Should().BeTrue();
|
||||
}
|
||||
|
||||
|
@ -68,19 +65,31 @@ namespace NzbDrone.Common.Test
|
|||
{
|
||||
var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
|
||||
|
||||
|
||||
_processProvider.GetProcessByName(DummyApp.DUMMY_PROCCESS_NAME).Should()
|
||||
.BeEmpty("Dummy process is already running");
|
||||
_processProvider.Start(startInfo).Should().NotBeNull();
|
||||
|
||||
_processProvider.GetProcessByName(DummyApp.DUMMY_PROCCESS_NAME).Should()
|
||||
Subject.GetProcessByName(DummyApp.DUMMY_PROCCESS_NAME).Should()
|
||||
.BeEmpty("Dummy process is already running");
|
||||
Subject.Start(startInfo).Should().NotBeNull();
|
||||
|
||||
Subject.GetProcessByName(DummyApp.DUMMY_PROCCESS_NAME).Should()
|
||||
.HaveCount(1, "excepted one dummy process to be already running");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void kill_all_should_kill_all_process_with_name()
|
||||
{
|
||||
var dummy1 = StartDummyProcess();
|
||||
var dummy2 = StartDummyProcess();
|
||||
|
||||
Subject.KillAll(dummy1.ProcessName);
|
||||
|
||||
dummy1.HasExited.Should().BeTrue();
|
||||
dummy2.HasExited.Should().BeTrue();
|
||||
}
|
||||
|
||||
public Process StartDummyProcess()
|
||||
{
|
||||
var startInfo = new ProcessStartInfo(DummyApp.DUMMY_PROCCESS_NAME + ".exe");
|
||||
return _processProvider.Start(startInfo);
|
||||
return Subject.Start(startInfo);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
|
@ -111,9 +112,14 @@ namespace NzbDrone.Common
|
|||
};
|
||||
}
|
||||
|
||||
public void KillAll(string nzbdrone)
|
||||
public virtual void KillAll(string processName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
var processToKill = GetProcessByName(processName);
|
||||
|
||||
foreach (var processInfo in processToKill)
|
||||
{
|
||||
Kill(processInfo.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -108,7 +108,6 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
{
|
||||
Name = "Address",
|
||||
Interval = 12
|
||||
|
||||
};
|
||||
|
||||
Subject.Insert(childModel);
|
||||
|
@ -118,8 +117,7 @@ namespace NzbDrone.Core.Test.Datastore
|
|||
|
||||
Subject.SetFields(childModel, t => t.Name);
|
||||
|
||||
Db.All<JobDefinition>().Single().Name.Should().Be("Address");
|
||||
Db.All<JobDefinition>().Single().Name.Should().Be("B");
|
||||
Db.All<JobDefinition>().Single().Name.Should().Be("A");
|
||||
Db.All<JobDefinition>().Single().Interval.Should().Be(12);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
@ -24,7 +25,7 @@ namespace NzbDrone.Core.Indexers.Nzbx
|
|||
var jsonReader = new JsonTextReader(new StreamReader(source));
|
||||
var feed = _serializer.Deserialize<List<NzbxRecentItem>>(jsonReader);
|
||||
|
||||
foreach (var item in feed)
|
||||
foreach (var item in feed.Where(c => !string.IsNullOrWhiteSpace(c.Name)))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -101,9 +101,8 @@ namespace NzbDrone.Update.Test
|
|||
|
||||
Mocker.Resolve<UpdateProvider>().Start(TARGET_FOLDER);
|
||||
|
||||
|
||||
Mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[0].Id), Times.Once());
|
||||
Mocker.GetMock<ProcessProvider>().Verify(c => c.Kill(proccesses[1].Id), Times.Once());
|
||||
|
||||
Mocker.GetMock<ProcessProvider>().Verify(c => c.KillAll(ProcessProvider.NzbDroneProcessName), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
|
||||
|
@ -63,21 +62,9 @@ namespace NzbDrone.Update.Providers
|
|||
|
||||
//TODO:Should be able to restart service if anything beyond this point fails
|
||||
logger.Info("Killing all running processes");
|
||||
var processes = _processProvider.GetProcessByName(ProcessProvider.NzbDroneProcessName);
|
||||
foreach (var processInfo in processes)
|
||||
{
|
||||
_processProvider.Kill(processInfo.Id);
|
||||
}
|
||||
|
||||
var consoleProcesses = _processProvider.GetProcessByName(ProcessProvider.NzbDroneConsoleProcessName);
|
||||
foreach (var processInfo in consoleProcesses)
|
||||
{
|
||||
appType = AppType.Console;
|
||||
_processProvider.Kill(processInfo.Id);
|
||||
}
|
||||
|
||||
logger.Info("Killing all orphan IISExpress processes");
|
||||
_processProvider.KillAll("NzbDrone");
|
||||
_processProvider.KillAll(ProcessProvider.NzbDroneConsoleProcessName);
|
||||
_processProvider.KillAll(ProcessProvider.NzbDroneProcessName);
|
||||
|
||||
logger.Info("Creating backup of existing installation");
|
||||
_diskProvider.CopyDirectory(targetFolder, _environmentProvider.GetUpdateBackUpFolder());
|
||||
|
|
Loading…
Reference in New Issue