Pin test environment to Production in IngressRateLimitingTests to stabilize assertions.

This commit is contained in:
Sipke Schoorstra 2026-05-31 14:44:34 +02:00
parent 37553a9713
commit 48c4259844
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F

View file

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.RateLimiting;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Elsa.Http.UnitTests.RateLimiting;
@ -419,7 +420,10 @@ public class IngressRateLimitingTests
private static WebApplicationBuilder CreateBuilder()
{
var builder = WebApplication.CreateSlimBuilder();
// Pin the environment to Production so the developer exception page does not swallow
// pipeline exceptions (e.g. an unregistered rate limiting policy) into a 500 response.
// Otherwise the FailsWhenPolicyIsNotRegistered assertion becomes environment-dependent and flaky.
var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions { EnvironmentName = Environments.Production });
builder.WebHost.UseTestServer();
return builder;
}