Skip to content

Commit 8e2a98e

Browse files
authored
Less flaky test assertions (#5462) (#5477)
(cherry picked from commit 26ccb7f)
1 parent 660fc4c commit 8e2a98e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/Tests/Search/Search/SearchApiTests.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,22 @@ public SearchApiRuntimeFieldsTests(ReadOnlyCluster cluster, EndpointUsage usage)
721721
protected override void ExpectResponse(ISearchResponse<Project> response)
722722
{
723723
response.Hits.Count.Should().BeGreaterThan(0);
724-
response.Hits.First().Should().NotBeNull();
725-
response.Hits.First().Fields.ValueOf<ProjectRuntimeFields, string>(p => p.StartedOnDayOfWeek).Should().NotBeNullOrEmpty();
726-
response.Hits.First().Fields.ValueOf<ProjectRuntimeFields, string>(p => p.ThirtyDaysFromStarted).Should().NotBeNullOrEmpty();
727-
response.Hits.First().Fields[RuntimeFieldName].As<string[]>().FirstOrDefault().Should().NotBeNullOrEmpty();
724+
725+
foreach (var hit in response.Hits)
726+
{
727+
hit.Should().NotBeNull();
728+
729+
if (hit.Source.StartedOn != default)
730+
{
731+
hit.Fields.ValueOf<ProjectRuntimeFields, string>(p => p.StartedOnDayOfWeek).Should().NotBeNullOrEmpty();
732+
hit.Fields.ValueOf<ProjectRuntimeFields, string>(p => p.ThirtyDaysFromStarted).Should().NotBeNullOrEmpty();
733+
}
734+
735+
if (!string.IsNullOrEmpty(hit.Source.Type))
736+
{
737+
hit.Fields[RuntimeFieldName].As<string[]>().FirstOrDefault().Should().NotBeNullOrEmpty();
738+
}
739+
}
728740
}
729741
}
730742
}

0 commit comments

Comments
 (0)