-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests and fix documentation not being published on package. (#16)
- Loading branch information
1 parent
79ed686
commit b31ac0d
Showing
8 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,3 +396,7 @@ FodyWeavers.xsd | |
|
||
# JetBrains Rider | ||
*.sln.iml | ||
|
||
# Custom | ||
**/TestResults | ||
**/coveragereport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
NapalmCodes.Aspire.Hosting.Krakend.Tests/AddKrakendTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Aspire.Hosting; | ||
using Aspire.Hosting.ApplicationModel; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System.Net.Sockets; | ||
|
||
namespace NapalmCodes.Aspire.Hosting.Krakend.Tests; | ||
|
||
public class AddKrakendTests | ||
{ | ||
[Fact] | ||
public void AddKrakendContainerAddsAnnotationMetadata() | ||
{ | ||
var appBuilder = DistributedApplication.CreateBuilder(); | ||
|
||
appBuilder.AddKrakend("krakend"); | ||
|
||
using var app = appBuilder.Build(); | ||
|
||
var appModel = app.Services.GetRequiredService<DistributedApplicationModel>(); | ||
|
||
var containerResource = Assert.Single(appModel.Resources.OfType<KrakendResource>()); | ||
Assert.Equal("krakend", containerResource.Name); | ||
|
||
var endpoints = containerResource.Annotations.OfType<EndpointAnnotation>(); | ||
Assert.Single(endpoints); | ||
|
||
var primaryEndpoint = Assert.Single(endpoints, e => e.Name == "http"); | ||
Assert.Equal(8080, primaryEndpoint.TargetPort); | ||
Assert.False(primaryEndpoint.IsExternal); | ||
Assert.Equal("http", primaryEndpoint.Name); | ||
Assert.Null(primaryEndpoint.Port); | ||
Assert.Equal(ProtocolType.Tcp, primaryEndpoint.Protocol); | ||
Assert.Equal("http", primaryEndpoint.Transport); | ||
Assert.Equal("http", primaryEndpoint.UriScheme); | ||
|
||
var containerAnnotation = Assert.Single(containerResource.Annotations.OfType<ContainerImageAnnotation>()); | ||
Assert.Equal(KrakendContainerImageTags.Tag, containerAnnotation.Tag); | ||
Assert.Equal(KrakendContainerImageTags.Image, containerAnnotation.Image); | ||
Assert.Equal(KrakendContainerImageTags.Registry, containerAnnotation.Registry); | ||
} | ||
|
||
[Fact] | ||
public async Task KrakendCreatesConnectionString() | ||
{ | ||
var appBuilder = DistributedApplication.CreateBuilder(); | ||
var krakend = appBuilder | ||
.AddKrakend("krakend") | ||
.WithEndpoint("http", e => e.AllocatedEndpoint = new AllocatedEndpoint(e, "localhost", 27000)); | ||
|
||
using var app = appBuilder.Build(); | ||
|
||
var appModel = app.Services.GetRequiredService<DistributedApplicationModel>(); | ||
|
||
var connectionStringResource = Assert.Single(appModel.Resources.OfType<KrakendResource>()) as IResourceWithConnectionString; | ||
var connectionString = await connectionStringResource.GetConnectionStringAsync(); | ||
|
||
Assert.Equal($"http://localhost:27000", connectionString); | ||
Assert.Equal("{krakend.bindings.http.url}", connectionStringResource.ConnectionStringExpression.ValueExpression); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
NapalmCodes.Aspire.Hosting.Krakend.Tests/NapalmCodes.Aspire.Hosting.Krakend.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" /> | ||
<PackageReference Include="xunit" Version="2.9.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\NapalmCodes.Aspire.Hosting.Krakend\NapalmCodes.Aspire.Hosting.Krakend.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
</Project> |
2 changes: 1 addition & 1 deletion
2
NapalmCodes.Aspire.Hosting.Krakend/KrakendContainerImageTags.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters