Add integration and unit tests for Notes API with PostgreSQL-based test hosting configuration
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Freman.Sample.Web.IntegrationTests.TestHost;
|
||||
|
||||
public sealed class SampleWebFactory(string connectionString) : WebApplicationFactory<Program>
|
||||
{
|
||||
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
||||
{
|
||||
builder.UseEnvironment("Testing");
|
||||
|
||||
builder.ConfigureAppConfiguration((_, config) =>
|
||||
{
|
||||
var overrides = new Dictionary<string, string?>
|
||||
{
|
||||
["ConnectionStrings:AppDb"] = connectionString,
|
||||
["ApplyMigrationsOnStartup"] = "false"
|
||||
};
|
||||
|
||||
config.AddInMemoryCollection(overrides);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user