Skip to content

Commit

Permalink
trying to fix deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
romankr committed Dec 2, 2023
1 parent 658f0dd commit 7a32aba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
using NSubstitute.ExceptionExtensions;
using OddsCollector.Functions.CommunicationServices;
using OddsCollector.Functions.CosmosDb;
Expand Down Expand Up @@ -79,7 +80,7 @@ public async Task Run_WithValidParameters_SendsEmails()

var token = new CancellationToken();

await function.Run(token).ConfigureAwait(false);
await function.Run(new TimerInfo(), token).ConfigureAwait(false);

await emailSenderMock.Received().SendEmailAsync(predictons, token);
await cosmosDbClientMock.Received().GetEventPredictionsAsync(token);
Expand All @@ -101,7 +102,7 @@ public async Task Run_WithException_DoesntFail()

var token = new CancellationToken();

await function.Run(token).ConfigureAwait(false);
await function.Run(new TimerInfo(), token).ConfigureAwait(false);

loggerMock.Received().LogError(exception, "Failed to send e-mail notification");
}
Expand Down
5 changes: 4 additions & 1 deletion OddsCollector.Functions/Functions/NotificationFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ internal sealed class NotificationFunction(ILogger<NotificationFunction>? logger
private readonly IEmailSender _sender = sender ?? throw new ArgumentNullException(nameof(sender));
private readonly ILogger<NotificationFunction> _logger = logger ?? throw new ArgumentNullException(nameof(logger));

// introducing empty timer to fix deployment
// apparently, Azure cannot process functions
// with only one argument that is cancellation token
[Function(nameof(NotificationFunction))]
public async Task Run([TimerTrigger("%NotificationFunction:TimerInterval%")] CancellationToken cancellationToken)
public async Task Run([TimerTrigger("%NotificationFunction:TimerInterval%")] TimerInfo _, CancellationToken cancellationToken)
{
try
{
Expand Down

0 comments on commit 7a32aba

Please sign in to comment.