Beispiel #1
0
        public async Task Notify_TitleContainsEndpoint(ProcessResult result)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.Notify(result);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonPropertyMatching(b => b.attachments[0].title, $"Tag cleanup complete on {settings.Endpoint}");
        }
Beispiel #2
0
        public async Task Notify_Fallback_IncludesProperties(ProcessResult result)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.Notify(result);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonPropertyMatching(b => b.attachments[0].fallback, $"Tag cleanup complete on {settings.Endpoint}: Removed {result.RemovedTags} tags, ignored {result.IgnoredTags} tags, {result.IgnoredRepos} repos, and {result.IgnoredProjects} projects$");
        }
Beispiel #3
0
        public async Task NotifyException_PayloadIsStackTrace(Exception dummy)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.NotifyUnhandledException(dummy);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonProperty <string>(b => b.attachments[0].text, $"```csharp\n{dummy.ToString()}\n```");
        }
Beispiel #4
0
        public async Task Notify_TitleLinkForcesHttpsIfMissingProto(ProcessResult result)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .With(f => f.Endpoint, "hcr.mydomain.net")
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.Notify(result);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonProperty <string>(b => b.attachments[0].title_link, "https://hcr.mydomain.net");
        }
Beispiel #5
0
        public async Task NotifyException_Fallback_IncludesMessage(Exception dummy)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .With(f => f.Nondestructive, false)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.NotifyUnhandledException(dummy);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonProperty <string>(b => b.attachments[0].fallback, $"Unhandled Exception encountered during tag cleanup: {dummy.Message}");
        }
Beispiel #6
0
        public async Task Notify_SkipsDryRun(ProcessResult result)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .With(f => f.Nondestructive, false)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.Notify(result);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonPropertyMatching(b => b.attachments[0].fallback, "^Tag cleanup complete on.*")
            .WithJsonPropertyMatching(b => b.attachments[0].title, "^Tag cleanup complete on.*");
        }
Beispiel #7
0
        public async Task NotifyException_SkipsDryRun(Exception dummy)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .With(f => f.Nondestructive, false)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.NotifyUnhandledException(dummy);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonPropertyMatching(b => b.attachments[0].fallback, "^Unhandled Exception encountered during tag cleanup.*")
            .WithJsonPropertyMatching(b => b.attachments[0].title, "^Unhandled Exception encountered during tag cleanup.*");
        }
Beispiel #8
0
        public async Task Notify_IncludesFields(ProcessResult result)
        {
            var settings = _fixture.Build <ApplicationSettings>()
                           .WithAutoProperties()
                           .With(f => f.SlackWebhook, MOCK_HOOK)
                           .Create();

            var _sut = new SlackResultNotifier(settings);

            await _sut.Notify(result);

            _http.ShouldHaveCalled(MOCK_HOOK)
            .WithVerb(HttpMethod.Post)
            .WithJsonProperty <string>(b => b.attachments[0].fields[0].title, "Removed Tags")
            .WithJsonProperty <int>(b => b.attachments[0].fields[0].value, result.RemovedTags)
            .WithJsonProperty <string>(b => b.attachments[0].fields[1].title, "Ignored Tags")
            .WithJsonProperty <int>(b => b.attachments[0].fields[1].value, result.IgnoredTags)
            .WithJsonProperty <string>(b => b.attachments[0].fields[2].title, "Ignored Repos")
            .WithJsonProperty <int>(b => b.attachments[0].fields[2].value, result.IgnoredRepos)
            .WithJsonProperty <string>(b => b.attachments[0].fields[3].title, "Ignored Projects")
            .WithJsonProperty <int>(b => b.attachments[0].fields[3].value, result.IgnoredProjects);
        }