mirror of https://github.com/lidarr/Lidarr
Fixed broken service tests.
This commit is contained in:
parent
b2cce4d4f0
commit
d8418b35e1
|
@ -10,7 +10,7 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private const string SERVICE_URL = "http://services.nzbdrone.com/reporting";
|
private const string SERVICE_URL = "http://stage.services.nzbdrone.com/reporting";
|
||||||
private const string PARSE_URL = SERVICE_URL + "/ParseError";
|
private const string PARSE_URL = SERVICE_URL + "/ParseError";
|
||||||
private const string EXCEPTION_URL = SERVICE_URL + "/ReportException";
|
private const string EXCEPTION_URL = SERVICE_URL + "/ReportException";
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using Ninject;
|
||||||
using NzbDrone.Common.Contract;
|
using NzbDrone.Common.Contract;
|
||||||
using NzbDrone.Services.Service.Repository.Reporting;
|
using NzbDrone.Services.Service.Repository.Reporting;
|
||||||
using Services.PetaPoco;
|
using Services.PetaPoco;
|
||||||
|
@ -13,6 +14,7 @@ namespace NzbDrone.Services.Service.Controllers
|
||||||
private readonly IDatabase _database;
|
private readonly IDatabase _database;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
[Inject]
|
||||||
public ExceptionController(IDatabase database)
|
public ExceptionController(IDatabase database)
|
||||||
{
|
{
|
||||||
_database = database;
|
_database = database;
|
||||||
|
|
|
@ -8,7 +8,7 @@ using NzbDrone.Services.Service.Repository.Reporting;
|
||||||
using NzbDrone.Services.Tests.Framework;
|
using NzbDrone.Services.Tests.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Services.Tests.ExceptionController
|
namespace NzbDrone.Services.Tests.ExceptionControllerTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ReportExistingFixture : ServicesTestBase
|
public class ReportExistingFixture : ServicesTestBase
|
|
@ -6,7 +6,7 @@ using NzbDrone.Common.Contract;
|
||||||
using NzbDrone.Services.Service.Repository.Reporting;
|
using NzbDrone.Services.Service.Repository.Reporting;
|
||||||
using NzbDrone.Services.Tests.Framework;
|
using NzbDrone.Services.Tests.Framework;
|
||||||
|
|
||||||
namespace NzbDrone.Services.Tests.ExceptionController
|
namespace NzbDrone.Services.Tests.ExceptionControllerTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ReportNewFixture : ServicesTestBase
|
public class ReportNewFixture : ServicesTestBase
|
|
@ -68,8 +68,8 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ExceptionController\ReportExistingFixture.cs" />
|
<Compile Include="ExceptionControllerTests\ReportExistingFixture.cs" />
|
||||||
<Compile Include="ExceptionController\ReportNewFixture.cs" />
|
<Compile Include="ExceptionControllerTests\ReportNewFixture.cs" />
|
||||||
<Compile Include="ReportingControllerFixture.cs" />
|
<Compile Include="ReportingControllerFixture.cs" />
|
||||||
<Compile Include="Framework\ServicesTestBase.cs" />
|
<Compile Include="Framework\ServicesTestBase.cs" />
|
||||||
<Compile Include="Framework\TestDbHelper.cs" />
|
<Compile Include="Framework\TestDbHelper.cs" />
|
||||||
|
|
|
@ -12,6 +12,12 @@ namespace NzbDrone.Services.Tests
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ReportingControllerFixture : ServicesTestBase
|
public class ReportingControllerFixture : ServicesTestBase
|
||||||
{
|
{
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
WithRealDb();
|
||||||
|
Mocker.Resolve<ExceptionController>();
|
||||||
|
}
|
||||||
|
|
||||||
ReportingController Controller
|
ReportingController Controller
|
||||||
{
|
{
|
||||||
|
@ -94,7 +100,6 @@ namespace NzbDrone.Services.Tests
|
||||||
{
|
{
|
||||||
var parseReport = CreateParseErrorReport();
|
var parseReport = CreateParseErrorReport();
|
||||||
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
Controller.ParseError(parseReport);
|
Controller.ParseError(parseReport);
|
||||||
|
|
||||||
|
@ -115,7 +120,6 @@ namespace NzbDrone.Services.Tests
|
||||||
|
|
||||||
parseReport1.Title = Guid.NewGuid().ToString();
|
parseReport1.Title = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
Controller.ParseError(parseReport1);
|
Controller.ParseError(parseReport1);
|
||||||
Controller.ParseError(parseReport2);
|
Controller.ParseError(parseReport2);
|
||||||
|
@ -130,7 +134,6 @@ namespace NzbDrone.Services.Tests
|
||||||
var parseReport1 = CreateParseErrorReport();
|
var parseReport1 = CreateParseErrorReport();
|
||||||
var parseReport2 = CreateParseErrorReport();
|
var parseReport2 = CreateParseErrorReport();
|
||||||
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
Controller.ParseError(parseReport1);
|
Controller.ParseError(parseReport1);
|
||||||
Controller.ParseError(parseReport2);
|
Controller.ParseError(parseReport2);
|
||||||
|
@ -138,27 +141,5 @@ namespace NzbDrone.Services.Tests
|
||||||
var reports = Db.Fetch<ParseErrorRow>();
|
var reports = Db.Fetch<ParseErrorRow>();
|
||||||
reports.Should().HaveCount(1);
|
reports.Should().HaveCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void exception_report_should_be_saved()
|
|
||||||
{
|
|
||||||
var exceptionReport = CreateExceptionReport();
|
|
||||||
|
|
||||||
WithRealDb();
|
|
||||||
|
|
||||||
Controller.ReportException(exceptionReport);
|
|
||||||
|
|
||||||
var exceptionRows = Db.Fetch<ExceptionRow>();
|
|
||||||
exceptionRows.Should().HaveCount(1);
|
|
||||||
exceptionRows.Single().IsProduction.Should().Be(exceptionReport.IsProduction);
|
|
||||||
exceptionRows.Single().Version.Should().Be(exceptionReport.Version);
|
|
||||||
exceptionRows.Single().Timestamp.Should().BeWithin(TimeSpan.FromSeconds(4)).Before(DateTime.Now);
|
|
||||||
exceptionRows.Single().UGuid.Should().Be(exceptionReport.UGuid);
|
|
||||||
|
|
||||||
exceptionRows.Single().Logger.Should().Be(exceptionReport.Logger);
|
|
||||||
exceptionRows.Single().LogMessage.Should().Be(exceptionReport.LogMessage);
|
|
||||||
exceptionRows.Single().String.Should().Be(exceptionReport.String);
|
|
||||||
exceptionRows.Single().Type.Should().Be(exceptionReport.Type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue