Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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