Skip to content

Commit 05b91a8

Browse files
committed
Move OpaqueId assertion into ExpectResponse
1 parent e2e402c commit 05b91a8

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/Tests/Tests/Search/Search/SearchApiTests.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,7 @@ public OpaqueIdApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(clu
374374

375375
protected override SearchRequest<Project> Initializer => new SearchRequest<Project>()
376376
{
377-
RequestConfiguration = new RequestConfiguration
378-
{
379-
OpaqueId = CallIsolatedValue
380-
},
377+
RequestConfiguration = new RequestConfiguration { OpaqueId = CallIsolatedValue },
381378
Scroll = "10m"
382379
};
383380

@@ -388,23 +385,27 @@ protected override LazyResponses ClientUsage() => Calls(
388385
requestAsync: (c, r) => c.SearchAsync<Project>(r)
389386
);
390387

391-
protected override void OnAfterCall(IElasticClient client)
388+
protected override void ExpectResponse(ISearchResponse<Project> response)
392389
{
393-
var tasks = client.ListTasks(d => d.RequestConfiguration(r => r.OpaqueId(CallIsolatedValue)));
390+
response.ShouldBeValid();
391+
392+
var tasks = Client.ListTasks(d => d.RequestConfiguration(r => r.OpaqueId(CallIsolatedValue)));
394393
tasks.Should().NotBeNull();
395394
foreach (var node in tasks.Nodes)
396395
{
397396
foreach (var task in node.Value.Tasks)
398397
{
399-
task.Value.Headers.Should().NotBeNull().And.NotBeEmpty();
400-
task.Value.Headers[RequestData.OpaqueIdHeader].Should().Be(CallIsolatedValue, $"OpaqueId {CallIsolatedValue} not found for task id {task.Key}");
398+
task.Value.Headers.Should().NotBeNull();
399+
if (task.Value.Headers.TryGetValue(RequestData.OpaqueIdHeader, out var opaqueIdValue))
400+
{
401+
opaqueIdValue.Should().Be(CallIsolatedValue, $"OpaqueId header {opaqueIdValue} did not match {CallIsolatedValue}");
402+
}
403+
else
404+
{
405+
Assert.True(false, $"No OpaqueId header for task {task.Key} and OpaqueId value {CallIsolatedValue}");
406+
}
401407
}
402408
}
403409
}
404-
405-
protected override void ExpectResponse(ISearchResponse<Project> response)
406-
{
407-
response.ShouldBeValid();
408-
}
409410
}
410411
}

0 commit comments

Comments
 (0)