Skip to content

Commit 83e087d

Browse files
HavenDVclaude
andcommitted
fix: Add CreateCapturingClient for MeaiMapping tests
Adds a capturing HTTP handler that intercepts requests to verify MEAI-to-Reka request mapping without calling the real API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 70dff06 commit 83e087d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/tests/Reka.IntegrationTests/Tests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using System.Text;
2+
using System.Text.Json;
3+
14
namespace Reka.IntegrationTests;
25

36
[TestClass]
@@ -26,4 +29,37 @@ public RekaClient GetAuthenticatedClient()
2629

2730
return api;
2831
}
32+
33+
private (RekaClient client, CaptureHandler capture) CreateCapturingClient()
34+
{
35+
var capture = new CaptureHandler();
36+
var httpClient = new HttpClient(capture)
37+
{
38+
BaseAddress = new Uri("https://api.reka.ai"),
39+
};
40+
var client = new RekaClient(httpClient: httpClient, disposeHttpClient: true);
41+
42+
return (client, capture);
43+
}
44+
45+
internal sealed class CaptureHandler : HttpMessageHandler
46+
{
47+
public JsonDocument? LastRequestBody { get; private set; }
48+
49+
protected override async Task<HttpResponseMessage> SendAsync(
50+
HttpRequestMessage request,
51+
CancellationToken cancellationToken)
52+
{
53+
if (request.Content is not null)
54+
{
55+
var body = await request.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
56+
LastRequestBody = JsonDocument.Parse(body);
57+
}
58+
59+
return new HttpResponseMessage(System.Net.HttpStatusCode.OK)
60+
{
61+
Content = new StringContent("{}", Encoding.UTF8, "application/json"),
62+
};
63+
}
64+
}
2965
}

0 commit comments

Comments
 (0)