Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit b9fd269

Browse files
committed
Make GetNotification nullable
1 parent 5519ad0 commit b9fd269

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/ApiService/ApiService/onefuzzlib/NotificationOperations.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public interface INotificationOperations : IOrm<Notification> {
99
IAsyncEnumerable<Notification> GetNotifications(Container container);
1010
IAsyncEnumerable<(Task, IEnumerable<Container>)> GetQueueTasks();
1111
Async.Task<OneFuzzResult<Notification>> Create(Container container, NotificationTemplate config, bool replaceExisting);
12-
Async.Task<Notification> GetNotification(Guid notifificationId);
12+
Async.Task<Notification?> GetNotification(Guid notifificationId);
1313
}
1414

1515
public class NotificationOperations : Orm<Notification>, INotificationOperations {
@@ -155,7 +155,7 @@ private async Async.Task<NotificationTemplate> HideSecrets(NotificationTemplate
155155
return null;
156156
}
157157

158-
public async Async.Task<Notification> GetNotification(Guid notifificationId) {
159-
return await SearchByPartitionKeys(new[] { notifificationId.ToString() }).SingleAsync();
158+
public async Async.Task<Notification?> GetNotification(Guid notifificationId) {
159+
return await SearchByPartitionKeys(new[] { notifificationId.ToString() }).SingleOrDefaultAsync();
160160
}
161161
}

src/ApiService/IntegrationTests/JinjaToScribanMigrationTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public async Async.Task Dry_Run_Does_Not_Make_Changes() {
4949
var dryRunResult = BodyAs<JinjaToScribanMigrationDryRunResponse>(result);
5050
dryRunResult.NotificationIdsToUpdate.Should().BeEquivalentTo(new List<Guid> { notificationBefore.NotificationId });
5151

52-
var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
52+
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
5353
var adoTemplateAfter = (notificationAfter.Config as AdoTemplate)!;
5454

5555
notificationBefore.Should().BeEquivalentTo(notificationAfter, options =>
@@ -88,7 +88,7 @@ public async Async.Task Migration_Happens_When_Not_Dry_run() {
8888
migrationResult.FailedNotificationIds.Should().BeEmpty();
8989
migrationResult.UpdatedNotificationIds.Should().BeEquivalentTo(new List<Guid> { notificationBefore.NotificationId });
9090

91-
var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
91+
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
9292
var adoTemplateAfter = (notificationAfter.Config as AdoTemplate)!;
9393

9494
adoTemplateBefore.Should().NotBeEquivalentTo(adoTemplateAfter);
@@ -172,7 +172,7 @@ public async Async.Task All_ADO_Fields_Are_Migrated() {
172172
migrationResult.FailedNotificationIds.Should().BeEmpty();
173173
migrationResult.UpdatedNotificationIds.Should().BeEquivalentTo(new List<Guid> { notificationBefore.NotificationId });
174174

175-
var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
175+
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
176176
var adoTemplateAfter = (notificationAfter.Config as AdoTemplate)!;
177177

178178
adoTemplateBefore.Should().NotBeEquivalentTo(adoTemplateAfter);
@@ -224,7 +224,7 @@ public async Async.Task All_Github_Fields_Are_Migrated() {
224224
migrationResult.FailedNotificationIds.Should().BeEmpty();
225225
migrationResult.UpdatedNotificationIds.Should().BeEquivalentTo(new List<Guid> { notificationBefore.NotificationId });
226226

227-
var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
227+
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
228228
var githubTemplateAfter = (notificationAfter.Config as GithubIssuesTemplate)!;
229229

230230
githubTemplateBefore.Should().NotBeEquivalentTo(githubTemplateAfter);
@@ -279,7 +279,7 @@ public async Async.Task Teams_Template_Not_Migrated() {
279279
migrationResult.FailedNotificationIds.Should().BeEmpty();
280280
migrationResult.UpdatedNotificationIds.Should().BeEmpty();
281281

282-
var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
282+
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
283283
var teamsTemplateAfter = (notificationAfter.Config as TeamsTemplate)!;
284284

285285
teamsTemplateBefore.Should().BeEquivalentTo(teamsTemplateAfter);
@@ -330,9 +330,9 @@ public async Async.Task Can_Migrate_Multiple_Notification_Configs() {
330330

331331
result.StatusCode.Should().Be(System.Net.HttpStatusCode.OK);
332332

333-
var teamsNotificationAfter = await Context.NotificationOperations.GetNotification(teamsNotificationBefore.NotificationId);
334-
var adoNotificationAfter = await Context.NotificationOperations.GetNotification(adoNotificationBefore.NotificationId);
335-
var githubNotificationAfter = await Context.NotificationOperations.GetNotification(githubNotificationBefore.NotificationId);
333+
var teamsNotificationAfter = (await Context.NotificationOperations.GetNotification(teamsNotificationBefore.NotificationId))!;
334+
var adoNotificationAfter = (await Context.NotificationOperations.GetNotification(adoNotificationBefore.NotificationId))!;
335+
var githubNotificationAfter = (await Context.NotificationOperations.GetNotification(githubNotificationBefore.NotificationId))!;
336336

337337
var migrationResult = BodyAs<JinjaToScribanMigrationResponse>(result);
338338
migrationResult.FailedNotificationIds.Should().BeEmpty();

0 commit comments

Comments
 (0)