Files
vegasco/tests/Vegasco.Server.Api.Tests.Integration/Info/GetServerInfoTests.cs

35 lines
1020 B
C#
Raw Normal View History

using FluentAssertions;
2024-08-23 18:55:05 +02:00
using FluentAssertions.Extensions;
using System.Net.Http.Json;
using Vegasco.Server.Api.Info;
2024-08-23 18:55:05 +02:00
namespace Vegasco.Server.Api.Tests.Integration.Info;
2024-08-23 18:55:05 +02:00
[Collection(SharedTestCollection.Name)]
public class GetServerInfoTests
{
private readonly WebAppFactory _factory;
2024-08-23 18:55:05 +02:00
public GetServerInfoTests(WebAppFactory factory)
{
_factory = factory;
}
2024-08-23 18:55:05 +02:00
[Fact]
public async Task GetServerInfo_ShouldReturnServerInfo_WhenCalled()
{
// Arrange
2024-08-23 18:55:05 +02:00
// Act
using HttpResponseMessage response = await _factory.HttpClient.GetAsync("/v1/info/server");
// Assert
response.IsSuccessStatusCode.Should().BeTrue();
var serverInfo = await response.Content.ReadFromJsonAsync<GetServerInfo.Response>();
serverInfo!.Environment.Should().NotBeEmpty();
serverInfo.CommitDate.Should().BeAfter(23.August(2024))
.And.NotBeAfter(DateTime.Now);
serverInfo.CommitId.Should().MatchRegex(@"[0-9a-f]{40}");
serverInfo.FullVersion.Should().MatchRegex(@"\d\.\d\.\d(-[0-9a-zA-Z]+)?(\+g?[0-9a-f]{10})?");
}
2024-08-23 18:55:05 +02:00
}