feat: add jetstream api router and error envelope

This commit is contained in:
Joseph Doherty
2026-02-23 05:58:34 -05:00
parent 7fe15d7ce1
commit 6d23e89fe8
6 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
using System.Text;
using NATS.Server.JetStream.Api;
namespace NATS.Server.Tests;
internal static class JetStreamApiFixture
{
private static readonly JetStreamApiRouter Router = new();
public static Task<JetStreamApiResponse> RequestAsync(string subject, string payload)
{
return Task.FromResult(Router.Route(subject, Encoding.UTF8.GetBytes(payload)));
}
}

View File

@@ -0,0 +1,12 @@
namespace NATS.Server.Tests;
public class JetStreamApiRouterTests
{
[Fact]
public async Task Unknown_js_api_subject_returns_structured_error()
{
var response = await JetStreamApiFixture.RequestAsync("$JS.API.BAD", "{}");
response.Error.ShouldNotBeNull();
response.Error!.Code.ShouldBe(404);
}
}