web: verze API na jednom místě a číslo verze v patičce

This commit is contained in:
PatTheEvil committed 2026-12-02 18:54:15 +01:00
1 parent 946ff5ce12
commit 5d8b71c435
11 files changed
+102 -18

No files matched your search

+1 -1
View File
@@ -61,7 +61,7 @@ public class CreateIssueRequestTests
public async Task Hlaseni_s_prilohou_jde_do_API_jako_multipart()
{
var handler = new RecordingHandler();
var api = new HelpdeskApiClient(new HttpClient(handler) { BaseAddress = new Uri("http://api/") });
var api = new HelpdeskApiClient(new HttpClient(handler) { BaseAddress = new ApiOptions { BaseUrl = "http://api/" }.VersionedBaseAddress() });
var issue = await api.CreateIssueAsync(
new CreateIssueRequest("Projektor", "Bliká.", 2, BuildingId: null, LocationDetail: "B-205"),
+31
View File
@@ -0,0 +1,31 @@
using Helpdesk.Web.Api;
using Helpdesk.Web.Infrastructure;
namespace Helpdesk.Web.Tests;
public class ApiVersioningTests
{
[Theory]
[InlineData("http://api:8080/")]
[InlineData("http://api:8080")]
public void Zaklad_adresy_obsahuje_verzi_API(string baseUrl) =>
Assert.Equal("http://api:8080/api/v1/", new ApiOptions { BaseUrl = baseUrl }.VersionedBaseAddress().ToString());
[Fact]
public void Relativni_cesta_se_slozi_pod_verzi()
{
var baseAddress = new ApiOptions { BaseUrl = "http://api:8080/" }.VersionedBaseAddress();
Assert.Equal("/api/v1/auth/login", new Uri(baseAddress, "auth/login").AbsolutePath);
}
}
public class AppVersionTests
{
[Theory]
[InlineData("0.2.0+6e742b4029cca8896173c0d64783b7fb7540f214", "0.2.0 (6e742b4)")]
[InlineData("0.2.0", "0.2.0")]
[InlineData(null, "neznámá")]
public void Verze_se_zobrazi_s_kratkym_hashem_commitu(string? informational, string expected) =>
Assert.Equal(expected, AppVersion.Format(informational));
}