namespace Cepis.Tests; /// The health endpoint, which reports rather than throws. public sealed class HealthTests : HttpTestBase { [Fact] public async Task ReadsAHealthyApi() { Server.Respond("/health", Reply.Of(200, Fixtures.Healthy)); var health = await Client.HealthAsync(); Assert.True(health.Ok); Assert.Equal("ok", health.Status); Assert.Equal("26071", health.Dne); Assert.Equal(1596168, health.Ceps); Assert.Equal(894489, health.Geo); Assert.Equal("2026-07-24T03:48:28Z", health.BaseGeradaEm); } [Fact] public async Task ADegradedApiReportsRatherThanThrows() { Server.Respond("/health", Reply.Of(503, """{"status":"degradado","dne":"26071","ceps":0,"geo":0,"base_gerada_em":""}""")); var health = await Client.HealthAsync(); Assert.False(health.Ok); Assert.Equal("degradado", health.Status); Assert.Equal(1, Server.Count("/health")); } [Fact] public async Task AnUnreachableApiStillThrows() { using var unreachable = new CepisClient(new CepisClientOptions { BaseUrl = "http://127.0.0.1:1", MaxAttempts = 1, Timeout = TimeSpan.FromSeconds(30), }); await Assert.ThrowsAsync(() => unreachable.HealthAsync()); } }