Skip to content

Commit

Permalink
refactor(slimfaas): add test to Program.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet committed Jun 22, 2023
1 parent cd79850 commit cca0a87
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/SlimFaas/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
.WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2,
retryAttempt)));
}

public partial class Program { }
25 changes: 25 additions & 0 deletions tests/SlimFaas.Tests/ProgramShould.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Net;
using Microsoft.Extensions.Logging;
using Moq;
using System.Text.Json;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;

namespace SlimFaas.Tests;

public class ProgramShould
{
[Fact]
public async Task TestRootEndpoint()
{
Environment.SetEnvironmentVariable("MOCK_REDIS", "true");
Environment.SetEnvironmentVariable("MOCK_KUBERNETES_FUNCTIONS", "{\"Functions\":[{\"Name\":\"fibonacci1\",\"NumberParallelRequest\":1},{\"Name\":\"fibonacci2\",\"NumberParallelRequest\":1}]}");
await using var application = new WebApplicationFactory<Program>();
using var client = application.CreateClient();

var response = await client.GetStringAsync("/health");

Assert.Equal("OK", response);
}
}
1 change: 1 addition & 0 deletions tests/SlimFaas.Tests/SlimFaas.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="KubernetesClient" Version="11.0.9" />
Expand Down

0 comments on commit cca0a87

Please sign in to comment.