diff options
| author | Patrick Barron <18354464+barronpm@users.noreply.github.com> | 2021-05-10 09:05:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-10 09:05:12 -0400 |
| commit | e55f35b62e5da535bfba301e5ac86f28df35dd2e (patch) | |
| tree | 02c1d449788be00877e3f53acde17638eadfc90a /tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs | |
| parent | 9413d974f3f234dd3fc2225d318d7fced7257912 (diff) | |
| parent | d4a50be22c3c4b9bb0adfb957ee558287fd219d9 (diff) | |
Merge branch 'master' into using-declarations
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs | 40 |
1 files changed, 40 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..0ade345a1 --- /dev/null +++ b/tests/Jellyfin.Server.Integration.Tests/OpenApiSpecTests.cs @@ -0,0 +1,40 @@ +using System.IO; +using System.Reflection; +using System.Threading.Tasks; +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); + } + } +} |
