mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 22:01:10 +00:00
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
#region ========================================================================= USING =====================================================================================
|
|
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
|
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
#endregion
|
|
|
|
namespace Lumina.Presentation.Web.IntegrationTests.Core.Health;
|
|
|
|
/// <summary>
|
|
/// Contains integration tests for the <c>/health/live</c> and <c>/health/ready</c> probe routes.
|
|
/// </summary>
|
|
[ExcludeFromCodeCoverage]
|
|
public class HealthEndpointTests : IClassFixture<LuminaWebFactory>
|
|
{
|
|
private readonly LuminaWebFactory _apiFactory;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="HealthEndpointTests"/> class.
|
|
/// </summary>
|
|
/// <param name="apiFactory">Injected Web application factory.</param>
|
|
public HealthEndpointTests(LuminaWebFactory apiFactory)
|
|
{
|
|
_apiFactory = apiFactory;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task HealthLive_WhenCalled_ShouldReturnOk()
|
|
{
|
|
// Arrange
|
|
HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
|
|
|
|
// Act
|
|
HttpResponseMessage response = await client.GetAsync("/health/live");
|
|
|
|
// Assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task HealthReady_WhenApiIsReachable_ShouldReturnHealthy()
|
|
{
|
|
// Arrange
|
|
HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
|
|
|
|
// Act
|
|
HttpResponseMessage response = await client.GetAsync("/health/ready");
|
|
string content = await response.Content.ReadAsStringAsync();
|
|
|
|
// Assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
Assert.Contains("Healthy", content, System.StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
}
|