Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Integration Tests #87

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions src/Content/Backend/Solution/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"keycloakConfig": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"defaultValue": "true",
"displayName": "Include Keycloak realm configuration",
"description": "Include Keycloak JSON configuration file for generating new realm"
},
Expand All @@ -73,7 +73,7 @@
"massTransitIntegration": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"defaultValue": "true",
"displayName": "Include MassTransit integration",
"description": "Includes MassTransit for integration events"
},
Expand All @@ -87,7 +87,7 @@
"workerService": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"defaultValue": "true",
"displayName": "Include Worker Service",
"description": "Include Worker Service project for background service implementation"
},
Expand Down Expand Up @@ -185,13 +185,26 @@
"condition": "(!apiService)",
"exclude": [
"Monaco.Template.Backend.Api/**/*",
"Monaco.Template.Backend.*.Api*/**/*"
"Monaco.Template.Backend.*.Api*/**/*",
"Monaco.Template.Backend.IntegrationTests/ApiRoutes.cs",
"Monaco.Template.Backend.IntegrationTests/Factories/ApiWebApplicationFactory.cs",
"Monaco.Template.Backend.IntegrationTests/Tests/CompaniesTests.cs",
"Monaco.Template.Backend.IntegrationTests/Tests/CountriesTests.cs",
"Monaco.Template.Backend.IntegrationTests/Tests/FilesTests.cs",
"Monaco.Template.Backend.IntegrationTests/Tests/ProductsTests.cs",
"Monaco.Template.Backend.IntegrationTests/Scripts/Companies.sql",
"Monaco.Template.Backend.IntegrationTests/Scripts/Products.sql",
"Monaco.Template.Backend.IntegrationTests/Imports/Pictures/**/*"
]
},
{
"condition": "(!auth)",
"condition": "(!apiService || !auth)",
"exclude": [
"Monaco.Template.Backend.Api/Auth/**/*"
"Monaco.Template.Backend.Api/Auth/**/*",
"Monaco.Template.Backend.IntegrationTests/Auth/AccessTokenDto.cs",
"Monaco.Template.Backend.IntegrationTests/Auth/Auth.cs",
"Monaco.Template.Backend.IntegrationTests/Auth/KeycloakService.cs",
"Monaco.Template.Backend.IntegrationTests/Imports/Keycloak/**/*"
]
},
{
Expand Down Expand Up @@ -240,8 +253,12 @@
"Monaco.Template.Backend.Domain.Tests/ImageDimensionsTests.cs",
"Monaco.Template.Backend.Domain.Tests/ImageTests.cs",
"Monaco.Template.Backend.Domain.Tests/ProductTests.cs",
"Monaco.Template.Backend.IntegrationTests/Imports/Pictures/**/*",
"Monaco.Template.Backend.IntegrationTests/Scripts/Products.sql",
"Monaco.Template.Backend.IntegrationTests/Tests/FilesTests.cs",
"Monaco.Template.Backend.IntegrationTests/Tests/ProductsTests.cs",
"Monaco.Template.Backend.Messages/V1/ProductCreated.cs",
"Monaco.Template.Backend.Service/Consumers/ProductCreatedConsumer.cs"
"Monaco.Template.Backend.Service/Consumers/OnProductCreatedThenLongRunningProcess.cs"
]
},
{
Expand All @@ -260,19 +277,27 @@
{
"condition": "(!massTransitIntegration || !workerService)",
"exclude": [
"Monaco.Template.Backend.Application/Features/Product/LongRunningProcessCommand.cs"
"Monaco.Template.Backend.Application/Features/Product/LongRunningProcess.cs"
]
},
{
"condition": "(!tests)",
"exclude": [
"Monaco.Template.Backend.*.Tests/**/*"
"Monaco.Template.Backend.*.Tests/**/*",
"Monaco.Template.Backend.*Tests/**/*"
]
},
{
"condition": "(!workerService)",
"exclude": [
"Monaco.Template.Backend.Service/**/*"
"Monaco.Template.Backend.Service/**/*",
"Monaco.Template.Backend.IntegrationTests/Factories/WorkerServiceFactory.cs"
]
},
{
"condition": "(!apiService && !workerService)",
"exclude": [
"Monaco.Template.Backend.Backend.IntegrationTests/**/*"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Monaco.Template.Backend.IntegrationTests" />
</ItemGroup>

<!--#if (templateDebug)-->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants);auth;commonLibraries;filesSupport</DefineConstants>
<DefineConstants>$(DefineConstants);auth;commonLibraries;filesSupport;massTransitIntegration</DefineConstants>
</PropertyGroup>

<!--#endif-->
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="8.0.1" />
<!--#if (massTransitIntegration)-->
<PackageReference Include="MassTransit.Azure.ServiceBus.Core" Version="8.2.5" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.2.5" />
<PackageReference Include="MassTransit.Azure.ServiceBus.Core" Version="8.3.6" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.6" />
<!--#endif-->
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
Expand Down
31 changes: 17 additions & 14 deletions src/Content/Backend/Solution/Monaco.Template.Backend.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
builder.Host.UseSerilog((context, config) => config.ReadFrom.Configuration(context.Configuration)
.WriteTo.Logger(l => l.WriteTo.Conditional(_ => context.HostingEnvironment.IsDevelopment(), // Only for dev
.WriteTo.Logger(l => l.WriteTo.Conditional(_ => context.HostingEnvironment.IsDevelopment(), // Only for dev
cfg => cfg.Debug()
.WriteTo.File("logs/log.txt",
rollingInterval: RollingInterval.Day,
Expand Down Expand Up @@ -71,18 +71,16 @@
#if (massTransitIntegration)
.AddMassTransit(cfg =>
{
if (builder.Environment.IsDevelopment())
cfg.UsingRabbitMq((_, busCfg) =>
{
var rabbitMqConfig = configuration.GetSection("MessageBus:RabbitMQ");
busCfg.Host(rabbitMqConfig["Host"],
rabbitMqConfig["VHost"],
h =>
{
h.Username(rabbitMqConfig["Username"]);
h.Password(rabbitMqConfig["Password"]);
});
});
var rabbitMqConfig = configuration.GetSection("MessageBus:RabbitMQ");
if (rabbitMqConfig.Exists())
cfg.UsingRabbitMq((_, busCfg) => busCfg.Host(rabbitMqConfig["Host"],
ushort.Parse(rabbitMqConfig["Port"] ?? "5672"),
rabbitMqConfig["VHost"],
h =>
{
h.Username(rabbitMqConfig["Username"]!);
h.Password(rabbitMqConfig["Password"]!);
}));
else
cfg.UsingAzureServiceBus((_, busCfg) => busCfg.Host(configuration["MessageBus:ASBConnectionString"]));
})
Expand Down Expand Up @@ -120,4 +118,9 @@

app.MapHealthChecks("/health", new HealthCheckOptions { Predicate = _ => true });

app.Run();
app.Run();

namespace Monaco.Template.Backend.Api
{
public partial class Program;
}
Loading