diff options
| author | BaronGreenback <jimcartlidge@yahoo.co.uk> | 2021-03-14 18:40:44 +0000 |
|---|---|---|
| committer | BaronGreenback <jimcartlidge@yahoo.co.uk> | 2021-03-14 18:40:44 +0000 |
| commit | 4c7680e186ec76053f6d54e29e5cd67c5a0b17f7 (patch) | |
| tree | cf21e8a3ac31487d4126aa0fceaa498473f02c43 /tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs | |
| parent | 6087831aa65398a6305570c4dc84f0bc2613b842 (diff) | |
| parent | bd70f562189e81d409caf2f4f67d8d495d4bbf1e (diff) | |
Merge remote-tracking branch 'upstream/master' into SubnetOverlappFix
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs b/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs new file mode 100644 index 000000000..3cbd638f9 --- /dev/null +++ b/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs @@ -0,0 +1,42 @@ +using System.IO; +using System.Reflection; +using System.Text.Json; +using System.Threading.Tasks; +using MediaBrowser.Model.Branding; +using Xunit; +using Xunit.Abstractions; + +namespace Jellyfin.Server.Integration.Tests +{ + public sealed class OpenApiSpecTests : IClassFixture<JellyfinApplicationFactory> + { + private readonly JellyfinApplicationFactory _factory; + private readonly ITestOutputHelper _outputHelper; + + public OpenApiSpecTests(JellyfinApplicationFactory factory, ITestOutputHelper outputHelper) + { + _factory = factory; + _outputHelper = outputHelper; + } + + [Fact] + public async Task GetSpec_ReturnsCorrectResponse() + { + // Arrange + var client = _factory.CreateClient(); + + // Act + var response = await client.GetAsync("/api-docs/openapi.json"); + + // Assert + response.EnsureSuccessStatusCode(); + Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType?.ToString()); + + // Write out for publishing + var responseBody = await response.Content.ReadAsStringAsync(); + string outputPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "openapi.json")); + _outputHelper.WriteLine("Writing OpenAPI Spec JSON to '{0}'.", outputPath); + File.WriteAllText(outputPath, responseBody); + } + } +} |
