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$"); }
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}"); }
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"); }
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.*"); }
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); }