Merge branch 'dev-test' into dev
This commit is contained in:
commit
132368bd23
|
@ -0,0 +1,15 @@
|
|||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Condition=" '$(TargetFramework)' == 'netcoreapp3.0' " Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Message Text="Copy db file -> $(TargetDir)" Importance="high" />
|
||||
<Copy Condition="'$(OS)' == 'Windows_NT'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)..\src\admin\keys\Longbow.lic" SkipUnchangedFiles="true" />
|
||||
<Copy Condition="'$(OS)' == 'UNIX'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)../src/admin/keys/Longbow.lic" SkipUnchangedFiles="true" />
|
||||
<Copy Condition="'$(OS)' == 'Windows_NT'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)..\src\admin\Bootstrap.Admin\BootstrapAdmin.db" SkipUnchangedFiles="true" />
|
||||
<Copy Condition="'$(OS)' == 'UNIX'" DestinationFolder="$(TargetDir)" SourceFiles="$(MSBuildThisFileDirectory)../src/admin/Bootstrap.Admin/BootstrapAdmin.db" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -1,5 +1,4 @@
|
|||
using Bootstrap.Admin.HealthChecks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
@ -8,8 +7,8 @@ using Microsoft.AspNetCore.Mvc.Testing;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using UnitTest;
|
||||
using Xunit;
|
||||
|
@ -88,18 +87,19 @@ namespace Bootstrap.Admin.Api
|
|||
services.AddDbAdapter();
|
||||
var builder = services.AddHealthChecks();
|
||||
builder.AddCheck<DBHealthCheck>("db");
|
||||
services.AddMvcCore();
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseRouting();
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
context.User = new System.Security.Claims.ClaimsPrincipal(new System.Security.Principal.GenericIdentity("Argo"));
|
||||
await next();
|
||||
});
|
||||
app.UseHealthChecks("/Healths", new HealthCheckOptions()
|
||||
app.UseEndpoints(builder => builder.MapHealthChecks("/Healths", new HealthCheckOptions()
|
||||
{
|
||||
ResponseWriter = (context, report) =>
|
||||
{
|
||||
|
@ -112,8 +112,7 @@ namespace Bootstrap.Admin.Api
|
|||
[HealthStatus.Degraded] = StatusCodes.Status200OK,
|
||||
[HealthStatus.Unhealthy] = StatusCodes.Status200OK
|
||||
}
|
||||
});
|
||||
app.UseMvcWithDefaultRoute();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +131,6 @@ namespace Bootstrap.Admin.Api
|
|||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override IWebHostBuilder CreateWebHostBuilder() => WebHost.CreateDefaultBuilder<TStartup>(null);
|
||||
protected override IHostBuilder CreateHostBuilder() => Host.CreateDefaultBuilder().ConfigureWebHostDefaults(builder => builder.UseStartup<TStartup>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Xunit;
|
||||
|
||||
namespace Bootstrap.Admin.Controllers.SQLServer
|
||||
namespace Bootstrap.Admin.Controllers.SqlServer
|
||||
{
|
||||
public class HealthCheck : ControllerTest
|
||||
{
|
||||
|
|
Binary file not shown.
|
@ -37,10 +37,6 @@ namespace UnitTest
|
|||
{
|
||||
if (providerName == DatabaseProviderType.SQLite)
|
||||
{
|
||||
var dbPath = RetrievePath($"UnitTest{Path.DirectorySeparatorChar}DB{Path.DirectorySeparatorChar}UnitTest.db");
|
||||
var dbFile = Path.Combine(AppContext.BaseDirectory, "UnitTest.db");
|
||||
File.Copy(dbPath, dbFile, true);
|
||||
|
||||
builder.ConfigureAppConfiguration(app => app.AddInMemoryCollection(new KeyValuePair<string, string>[] {
|
||||
new KeyValuePair<string, string>("DB:0:Enabled", "false"),
|
||||
new KeyValuePair<string, string>("DB:1:Enabled", "true")
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.msbuild" Version="2.7.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="1.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.0" />
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"Enabled": false,
|
||||
"ProviderName": "Sqlite",
|
||||
"ConnectionStrings": {
|
||||
"ba": "Data Source=UnitTest.db;"
|
||||
"ba": "Data Source=BootstrapAdmin.db;"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue