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

Commit

Permalink
Make GetNotification nullable (#2981)
Browse files Browse the repository at this point in the history
  • Loading branch information
tevoinea authored Apr 5, 2023
1 parent 5519ad0 commit 363cae0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface INotificationOperations : IOrm<Notification> {
IAsyncEnumerable<Notification> GetNotifications(Container container);
IAsyncEnumerable<(Task, IEnumerable<Container>)> GetQueueTasks();
Async.Task<OneFuzzResult<Notification>> Create(Container container, NotificationTemplate config, bool replaceExisting);
Async.Task<Notification> GetNotification(Guid notifificationId);
Async.Task<Notification?> GetNotification(Guid notifificationId);
}

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

public async Async.Task<Notification> GetNotification(Guid notifificationId) {
return await SearchByPartitionKeys(new[] { notifificationId.ToString() }).SingleAsync();
public async Async.Task<Notification?> GetNotification(Guid notifificationId) {
return await SearchByPartitionKeys(new[] { notifificationId.ToString() }).SingleOrDefaultAsync();
}
}
16 changes: 8 additions & 8 deletions src/ApiService/IntegrationTests/JinjaToScribanMigrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Async.Task Dry_Run_Does_Not_Make_Changes() {
var dryRunResult = BodyAs<JinjaToScribanMigrationDryRunResponse>(result);
dryRunResult.NotificationIdsToUpdate.Should().BeEquivalentTo(new List<Guid> { notificationBefore.NotificationId });

var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
var adoTemplateAfter = (notificationAfter.Config as AdoTemplate)!;

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

var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
var adoTemplateAfter = (notificationAfter.Config as AdoTemplate)!;

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

var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
var adoTemplateAfter = (notificationAfter.Config as AdoTemplate)!;

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

var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
var githubTemplateAfter = (notificationAfter.Config as GithubIssuesTemplate)!;

githubTemplateBefore.Should().NotBeEquivalentTo(githubTemplateAfter);
Expand Down Expand Up @@ -279,7 +279,7 @@ public async Async.Task Teams_Template_Not_Migrated() {
migrationResult.FailedNotificationIds.Should().BeEmpty();
migrationResult.UpdatedNotificationIds.Should().BeEmpty();

var notificationAfter = await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId);
var notificationAfter = (await Context.NotificationOperations.GetNotification(notificationBefore.NotificationId))!;
var teamsTemplateAfter = (notificationAfter.Config as TeamsTemplate)!;

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

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

var teamsNotificationAfter = await Context.NotificationOperations.GetNotification(teamsNotificationBefore.NotificationId);
var adoNotificationAfter = await Context.NotificationOperations.GetNotification(adoNotificationBefore.NotificationId);
var githubNotificationAfter = await Context.NotificationOperations.GetNotification(githubNotificationBefore.NotificationId);
var teamsNotificationAfter = (await Context.NotificationOperations.GetNotification(teamsNotificationBefore.NotificationId))!;
var adoNotificationAfter = (await Context.NotificationOperations.GetNotification(adoNotificationBefore.NotificationId))!;
var githubNotificationAfter = (await Context.NotificationOperations.GetNotification(githubNotificationBefore.NotificationId))!;

var migrationResult = BodyAs<JinjaToScribanMigrationResponse>(result);
migrationResult.FailedNotificationIds.Should().BeEmpty();
Expand Down

0 comments on commit 363cae0

Please sign in to comment.