(based on Radarr Commits 9e175e28efcfc6ac3e414649b955a10fb0e951e7 4f5f9ff77ee4de05ba04cc677eb7baf4df726af5 4ebcbc28aa3e3268ecc37c5fc2b5565da8f13305 ) Fixes #723 Co-authored-by: Qstick <qstick@gmail.com>pull/728/head
parent
80c31e8660
commit
5e3322c538
@ -0,0 +1,90 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using FluentAssertions;
|
||||||
|
using FluentValidation.Results;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Notifications;
|
||||||
|
using NzbDrone.Core.ThingiProvider;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.NotificationTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class NotificationBaseFixture : TestBase
|
||||||
|
{
|
||||||
|
private class TestSetting : IProviderConfig
|
||||||
|
{
|
||||||
|
public NzbDroneValidationResult Validate()
|
||||||
|
{
|
||||||
|
return new NzbDroneValidationResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestNotificationWithApplicationUpdate : NotificationBase<TestSetting>
|
||||||
|
{
|
||||||
|
public override string Name => "TestNotification";
|
||||||
|
public override string Link => "";
|
||||||
|
|
||||||
|
public override ValidationResult Test()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||||
|
{
|
||||||
|
TestLogger.Info("OnApplicationUpdate was called");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestNotificationWithAllEvents : NotificationBase<TestSetting>
|
||||||
|
{
|
||||||
|
public override string Name => "TestNotification";
|
||||||
|
public override string Link => "";
|
||||||
|
|
||||||
|
public override ValidationResult Test()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnHealthIssue(NzbDrone.Core.HealthCheck.HealthCheck artist)
|
||||||
|
{
|
||||||
|
TestLogger.Info("OnHealthIssue was called");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage)
|
||||||
|
{
|
||||||
|
TestLogger.Info("OnApplicationUpdate was called");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestNotificationWithNoEvents : NotificationBase<TestSetting>
|
||||||
|
{
|
||||||
|
public override string Name => "TestNotification";
|
||||||
|
public override string Link => "";
|
||||||
|
|
||||||
|
public override ValidationResult Test()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_support_all_if_implemented()
|
||||||
|
{
|
||||||
|
var notification = new TestNotificationWithAllEvents();
|
||||||
|
|
||||||
|
notification.SupportsOnHealthIssue.Should().BeTrue();
|
||||||
|
notification.SupportsOnApplicationUpdate.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_support_none_if_none_are_implemented()
|
||||||
|
{
|
||||||
|
var notification = new TestNotificationWithNoEvents();
|
||||||
|
|
||||||
|
notification.SupportsOnHealthIssue.Should().BeFalse();
|
||||||
|
notification.SupportsOnApplicationUpdate.Should().BeFalse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(014)]
|
||||||
|
public class add_on_update_to_notifications : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Alter.Table("Notifications").AddColumn("OnApplicationUpdate").AsBoolean().WithDefaultValue(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Notifications
|
||||||
|
{
|
||||||
|
public class ApplicationUpdateMessage
|
||||||
|
{
|
||||||
|
public string Message { get; set; }
|
||||||
|
public Version PreviousVersion { get; set; }
|
||||||
|
public Version NewVersion { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return NewVersion.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
using NzbDrone.Core.HealthCheck;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Notifications.Webhook
|
||||||
|
{
|
||||||
|
public class WebhookApplicationUpdatePayload : WebhookPayload
|
||||||
|
{
|
||||||
|
public string Message { get; set; }
|
||||||
|
public string PreviousVersion { get; set; }
|
||||||
|
public string NewVersion { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue