blob: 17a8a552221ea0057996cb9f971e5bf14c370e4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
using Xunit;
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", TestContext.Current.CancellationToken);
// Assert
response.EnsureSuccessStatusCode();
Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType?.ToString());
// Write out for publishing
string outputPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? ".", "openapi.json"));
_outputHelper.WriteLine("Writing OpenAPI Spec JSON to '{0}'.", outputPath);
await using var fs = AsyncFile.Create(outputPath);
await response.Content.CopyToAsync(fs, TestContext.Current.CancellationToken);
}
}
}
|