Skip to content

Commit

Permalink
Wait async launch
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Oct 17, 2023
1 parent 926d6fe commit 47acad2
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using FluentAssertions;
using ReportPortal.Client.Abstractions.Requests;
using ReportPortal.Client.Abstractions.Responses;
using System;
using System.Threading.Tasks;
using Xunit;
Expand Down Expand Up @@ -36,10 +37,13 @@ public async Task StartFinishDeleteLaunch()
var message = await Service.AsyncLaunch.FinishAsync(launch.Uuid, finishLaunchRequest);
Assert.Equal(launch.Uuid, message.Uuid);

// race condition: get a chance the launch is in database before deleting it
await Task.Delay(10_000);
LaunchResponse gotLaunch = null;

var gotLaunch = await Service.Launch.GetAsync(launch.Uuid);
// wait until async launch will be processed
Func<Task> getLaunchAction = async () => gotLaunch = await Service.Launch.GetAsync(launch.Uuid);
await getLaunchAction.Should().NotThrowAfterAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(1));

Assert.NotNull(gotLaunch);
Assert.Equal("StartFinishDeleteAsyncLaunch", gotLaunch.Name);
gotLaunch.StartTime.Should().BeCloseTo(startLaunchRequest.StartTime, precision: 1);
gotLaunch.EndTime.Should().BeCloseTo(finishLaunchRequest.EndTime, precision: 1);
Expand Down

0 comments on commit 47acad2

Please sign in to comment.