Merge pull request #4046 from jellyfin/EraYaN-ci-publish-openapi-spec
Enable code coverage and upload OpenAPI spec.pull/4062/head
commit
1f431323f3
@ -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.Api.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,34 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.7" />
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
|
||||||
<PackageReference Include="xunit" Version="2.4.1" />
|
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
|
||||||
<PackageReference Include="coverlet.collector" Version="1.3.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\Jellyfin.Server\Jellyfin.Server.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Code Analyzers -->
|
|
||||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
|
|
||||||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
|
||||||
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
Loading…
Reference in new issue