0
0
mirror of https://github.com/alex289/CleanArchitecture.git synced 2025-06-29 18:21:08 +00:00
CleanArchitecture/CleanArchitecture.IntegrationTests/UtilityTests/HealthChecksTests.cs
2025-03-16 00:23:50 +01:00

31 lines
957 B
C#

using System.Net;
using System.Threading.Tasks;
using CleanArchitecture.IntegrationTests.Fixtures;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Newtonsoft.Json.Linq;
using Shouldly;
namespace CleanArchitecture.IntegrationTests.UtilityTests;
public sealed class HealthChecksTests
{
private readonly AuthTestFixure _fixture = new();
[OneTimeSetUp]
public async Task Setup() => await GlobalSetupFixture.RespawnDatabaseAsync();
[Test, Order(0)]
public async Task Should_Return_Healthy()
{
// Wait some time to let the services get healthy
await Task.Delay(2000);
var response = await _fixture.ServerClient.GetAsync("/healthz");
response.StatusCode.ShouldBe(HttpStatusCode.OK);
var content = await response.Content.ReadAsStringAsync();
var json = JObject.Parse(content);
json["status"]!.Value<string>().ShouldBe(HealthStatus.Healthy.ToString());
}
}