30 lines
976 B
C#
30 lines
976 B
C#
using System.Net.Http.Json;
|
|||
|
|
using System.Text.Json;
|
||
|
|
using Shouldly;
|
||
|
|
|
||
|
|
namespace Heimdall.IntegrationTests.Controllers;
|
||
|
|
|
||
|
|
public class HealthControllerTests : PostgresTestBase
|
||
|
|
{
|
||
|
|
public HealthControllerTests(PostgreSqlContainerFixture postgres) : base(postgres) { }
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public async Task Health_ReturnsOk()
|
||
|
|
{
|
||
|
|
var client = Factory.CreateClient();
|
||
|
|
var response = await client.GetAsync("/healthz");
|
||
|
|
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
||
|
|
|
||
|
|
var content = await response.Content.ReadFromJsonAsync<JsonElement>();
|
||
|
|
content.GetProperty("status").GetString().ShouldBe("healthy");
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public async Task Health_ReturnsTimestamp()
|
||
|
|
{
|
||
|
|
var client = Factory.CreateClient();
|
||
|
|
var response = await client.GetAsync("/healthz");
|
||
|
|
var content = await response.Content.ReadFromJsonAsync<JsonElement>();
|
||
|
|
content.TryGetProperty("timestamp", out _).ShouldBeTrue();
|
||
|
|
}
|
||
|
|
}
|